RegEx lookbehind assertion question Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
afe
Posts: 577
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: 613
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: 6844
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”

Who is online

Users browsing this forum: Bing [Bot], djuga22, hotkeyguy, joefiesta, scriptor2016, swagfag and 197 guests