LangProc / langproc-2021-lab

2 stars 4 forks source link

When to use \ to escape operators in square brackets? #64

Closed dharmilshah99 closed 2 years ago

dharmilshah99 commented 2 years ago

The . operator doesn't seem to need escaping in [.] if we just want to match ..

What operators are treated as regular characters in square brackets? Is there any documentation for this?

ymherklotz commented 2 years ago

There is quite good documentation of flex in their man page:

man 1 flex

Or you can also see it here: http://dinosaur.compilertools.net/flex/manpage.html

It says the following:

Note that inside of a character class, all regular expression operators lose their special meaning except escape ('\') and the character class operators, '-', ']', and, at the beginning of the class, '^'.

dharmilshah99 commented 2 years ago

This was really helpful. Thanks!