Help with RegEx and new line

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Help with RegEx and new line

16 Sep 2017, 14:45

I have an issue

Code: Select all

Msgbox % RegExMatch( " abc`n def", " abc`a def", matchObj )
All I want to do is match any new line in the needle ( putting `n won't help here )
The docs stated that
`a
In v1.0.46.06+, `a recognizes any type of newline, namely `r, `n, `r`n, `v/VT/vertical tab/chr(0xB), `f/FF/formfeed/chr(0xC), and NEL/next-line/chr(0x85). In v1.0.47.05+, newlines can be restricted to only CR, LF, and CRLF by instead specifying (*ANYCRLF) in uppercase at the beginning of the pattern (after the options); e.g. im)(*ANYCRLF)^abc$.
How do I use this feature?
Note:

Code: Select all

Msgbox % RegExMatch( " abc`n def", "`a)`a", matchObj )
doesn't work either
Recommends AHK Studio
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Help with RegEx and new line

16 Sep 2017, 14:54

That is for the options before the ) at the beginning of the needle, I haven't used it. I use \R in the needle to match new lines.
Cheers.
Edit 2:
Example usage msgbox % regexmatch("xyz`rabc","`am)^abc$") compare to msgbox % regexmatch("xyz`rabc","m)^abc$")
Spoiler
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Help with RegEx and new line

16 Sep 2017, 15:09

Thanks \R will do the job - however this is still an issue.
Recommends AHK Studio
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Help with RegEx and new line

16 Sep 2017, 15:20

Did you see my edit? It goes together with the m option.
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Help with RegEx and new line

16 Sep 2017, 15:35

Then the help description is just terrible here :|
Thanks for your help.
Recommends AHK Studio

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: JPMuir and 327 guests