RegEx lookbehind assertion question Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
afe
Posts: 615
Joined: 06 Dec 2018, 04:36

RegEx lookbehind assertion question

18 Jun 2019, 07:35

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.
User avatar
sinkfaze
Posts: 616
Joined: 01 Oct 2013, 08:01

Re: RegEx lookbehind assertion question  Topic is solved

18 Jun 2019, 14:16

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 +.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: RegEx lookbehind assertion question

18 Jun 2019, 16:48

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Lamron750, Rohwedder and 268 guests