Page 1 of 1

RegEx lookbehind assertion question

Posted: 18 Jun 2019, 07:35
by afe
Hello,

In the look-behind assertionn, can't the condition be an option with a Non-fixed length?
For example, in the following example, I tried to match bc in abc,d with [^,]+. The expected result is d.

Code: Select all

abc,d

(?<=a[^,]+,)\w
Thanks.

Re: RegEx lookbehind assertion question  Topic is solved

Posted: 18 Jun 2019, 14:16
by sinkfaze
Look-ahead and look-behind assertions wrote: Look-behinds are more limited than look-aheads because they do not support quantifiers of varying size such as *, ?, and +.

Re: RegEx lookbehind assertion question

Posted: 18 Jun 2019, 16:48
by jeeswg
You can try \K:

Code: Select all

q:: ;test RegExMatch \K
RegExMatch("abc,d", "O)a[^,]+,\K\w", oMatch)
MsgBox, % oMatch.0
RegExMatch("abc,d", "O)a[^,]+,(\w)", oMatch)
MsgBox, % oMatch.1
return