Sublime Forum

UI regex: allow the OR operation for look-behind regex

#1

As the title says.
With Find_in_files and the like, the regex doesnt allow the OR operation with look-behind (negative and positive).

Example:

/\w+(?<=Sublime|Bob)/

The regex above gives the error:

Invalid lookbehind assertion encountered in the regular expression. in regular expression /\w+(?<=Sublime|Bob)/

BUT accepts this:

/\w+(?<=Sublime)(?<=Bob)/

I would like the app to support the OR operation for the regex look-behind

Other Details

Even this is not accepted by the app:

/\w+(?<=(?:Sublime|Bob))/
0 Likes

More regex flavours for Find_in_files and the like
#2

Presumably this works:
\w+(?:(?<=Sublime)|(?<=Bob))

0 Likes

#3

It uses boost regex iirc. https://www.boost.org/doc/libs/1_33_1/libs/regex/doc/syntax_perl.html

(?<=pattern) consumes zero characters, only if pattern could be matched against the characters preceding the current position ( pattern must be of fixed length).

pattern must be of fixed length

So /\w+(?<=(?:Amy|Bob))/ can work because they have the same length but that’s quite limited.

0 Likes

#4

Seems we need a better one then

0 Likes

#5

Specifically for this case,

\w+(?:Sublime|Bob) is probably equivalent

0 Likes

#6

No, it’s not the equivalent.
That’s the thing, I’m not looking for an alternative. I just want the OR operator allowed in the look-behind.

0 Likes

#7

Mind providing a counter case? Just for my curiosity.

0 Likes

#8

We try to provide alternatives. And we know, it’s unlikely to be supported unless upstream (Boost lib) supports that.

0 Likes

#9

Alright then.

0 Likes