0

I'm trying to match a character constant. I only want single characters and a few escape sequences rather than \ followed by any letter.

This is very similar to this question with the added requirement of specific escape characters. Regular expression to match escaped characters (quotes)

'(\\\[tvrnafb\\\]|.)'
Community
  • 1
  • 1
AlexLordThorsen
  • 7,354
  • 3
  • 42
  • 93

1 Answers1

3

I feel dumb, I just had to remove the period in the other answer and add another character class.

'(\\[tvrnafb\\]|[^\\'])'
AlexLordThorsen
  • 7,354
  • 3
  • 42
  • 93