Regular expression lookaround support in 'Find'?


I am trying to use a negative lookbehind assertion in a regex “Find” in the editor. Specifically “(?<!^)\s”, that is to say “a whitespace character that is not preceded by the beginning of a line”. The editor responds with “Invalid regular expression: /(?<!^)\s/: Invalid group”. This leads me to assume that either Atom does not support lookaround assertions, or uses some other syntax that I’m not aware of.

Can someone either confirm that lookaround assertions are unsupported, or point me towards the correct syntax please? Google searches have been fruitless.



The syntax Atom uses for regular expressions is Oniguruma, which supports the look behind assertion syntax you tried. I’ve used look behind assertions in Atom plenty of times when working on language grammars without any issues. So unless the engine “Find” is using is different from the one used for language grammars the error is probably either because look behinds are restricted in “Find” or due to an error in how “Find” is interacting with the regex engine. On a side note, I just tried an expression, in Find, with a look ahead and it worked as expected.


Oniguruma is only used for grammars, it allow to reuse TextMate and SublimeText tmLanguage files. But everywhere else the JavaScript RegExp are used, and so lookbehind (positive and negative) aren’t supported.


I suspected that was the case, abe. Thanks to both both of you for responding.