Sublime Forum

RegEx lookaround bug

#1

…text text text. "Text text text…

Why this RegEx code (?<=\.|!"|\?") (?="[A-Z]) doesn’t work in Sublime Text, for the text as above? Though it works in Subtitle Edit…

The workaround ((?<=\.)|(?<=!")|(?<=\?")) (?="[A-Z]) works fine.

0 Likes

#2

Lookbehinds must be fixed length. See https://perldoc.perl.org/perlre#(*positive_lookbehind:pattern) and https://www.boost.org/doc/libs/1_66_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

0 Likes

#3

So maybe switch from Perl engine to another (like .NET engine), which doesn’t have such unreasonable restriction?

0 Likes

#4

The day ST requires .NET is the day to abandon it.

0 Likes

#5

Well, for me that day could be when they doesn’t support lookbehind in a correct way :slight_smile:

0 Likes

#6

It is the correct way to support lookbehinds in a PCRE compatible way.

I guess if someone manages to convince boost and/or Oniguruma developers to support variable length lookbehinds, ST would start supporting them at some point, too.

See: https://github.com/boostorg/regex/issues/170

2 Likes