slevithan / xregexp

Extended JavaScript regular expressions
http://xregexp.com/
MIT License
3.31k stars 278 forks source link

What does 'scope' mean in XRegExp? #266

Closed dzcpy closed 5 years ago

dzcpy commented 5 years ago

Sorry if it's not a proper question, but I couldn't find any documentation explaining what does scope (default / class etc.) actually do. Can anyone shed me some light on this?

josephfrazier commented 5 years ago

Assuming you're talking about the variables shown here: https://github.com/slevithan/xregexp/blob/2cb340a819b290c2d8638965fb7e825cfc0efbc4/src/xregexp.js#L41-L50

I believe they're used to implement the correct escape character behavior inside characters class (e.g. [a-z]), which is different from the escaping behavior outside character classes. See here for more information on the difference: https://www.regular-expressions.info/charclass.html#special