GREP: Repetition (*, +) at the end of a Positive Lookbehind group doesn't seem to work
Product: Adobe InDesign CC 2019 (14.01)
Steps to reproduce:
- Create a document with the text "abcde"
- (Case 1) Do a GREP search for "(?<=bc+)d"
- (Case 1) Do a GREP search for "(?<=bc*)d"
Expected result: highlight the "d"
Actual result: Cannot find match.
Note that searching for "(?<=bc)d" does work, as do of course "(?<b)c*d" and "(?=b)c+d".
Note also that this applied to GREP Styles in a paragraph style.
Does including bc in a Character Set, like:
work for you?
Jean-Claude Tremblay commented
Quantifiers like ? + * are not allowed in Lookbehind. That’s a limitation in Regex.
In Indesign you can use the \K to go around this.
So this will works.
I believe multipliers are not allowed in the look ahead/behind syntax as they can make the confirmation match much to broad.
In a search and replace scenario, I use sets to identify the targets so (?<=bc*)d would work like (?<=b)(c*)(d) if you identify your change onto $2 [assuming that c*($1) was not intended to change]
This wouldn't work with a style change.