Page 1 of 1

Need help with regex matching

Posted: 19 Feb 2017, 08:45
by Killaz
Hello. I have this code right here:

Code: Select all

Str := "The President: [Quiet: We do have economic problems]"
RegExMatch(Str, "^.*: \K.*", m)
MsgBox % m
What I basically need is to match all characters that come after the first ":", but for some reason Regex matches whatever comes after the second one.


Thanks. <3

Re: Need help with regex matching

Posted: 19 Feb 2017, 10:48
by Ovg
Why not use "(?<=:).*"

Re: Need help with regex matching  Topic is solved

Posted: 19 Feb 2017, 10:52
by jeeswg
It just needed a ? to make it ungreedy:

Code: Select all

;before the first ':'
Str := "The President: [Quiet: We do have economic problems]"
RegExMatch(Str, "^.*?(?=:)", m)
MsgBox % m

;after the first ': '
Str := "The President: [Quiet: We do have economic problems]"
RegExMatch(Str, "^.*?: \K.*", m)
MsgBox % m
Return