mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
I'm on mIRC v7.67, Windows 10 64bit.

when using anchors "^" "$" in multi-line mode, the anchors change from start/end of string, to start/end of line. In the example below, "$" is still treated as end of string, but "^" behaves correctly, both these expressions should pass, the first fails, the second passes.

//var %str = $+(abc,$crlf,def,$crlf,ghi) , %pat1 = /^def$/m , %pat2 = /^ghi$/m | echo -a $regex(%str,%pat1) vs $regex(%str,%pat2)

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
This is not a bug, mirc use pcre with its default line sequence of $lf, this has bien discussed not too long ago with khaled asking if he should make it $crlf.

Nobody answered that question positively, which is good, we dont actuelly want crlf, lf is default and is more compatible, it's just a thing to be aware of


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 1,360
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,360
Works correctly with $lf instead of $crlf

Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
The problem was reading files, windows encoding uses \r\n for newlines on files, hence why the example showed using $crlf to mimic a file-read.

Diving further into PCRE, there are various pattern modifiers to force mode flags, like (*UTF), (*UTF8), etc.... I guess there's also one for triggering any sequence of newline encoding (windows \r\n for instance) For anyone else experiencing this issue, the way to do it is (*ANYCRLF)

Example:

//var %str = $+(abc,$crlf,def,$crlf,ghi) , %pat1 = /(*ANYCRLF)^def$/m , %pat2 = /^def$/m | echo -a Success! $regex(%str,%pat1) Fail: $regex(%str,%pat2)


Link Copied to Clipboard