$regsub: intended behavior? - 21/07/14 02:48 AM
Is this the intended behavior?
1.
//echo 12 -ag $regsub(Replace myfixed., myfixed, fixed, %var) | echo 12 -ag VAR: %var
Result:
VAR: Replace myfixed.
(myfixed replaced with "myfixed" instead of "fixed".)
2.
//echo 12 -ag $regsub(Replace Xyfixed., Xyfixed, fixed, %var) | echo 12 -ag VAR: %var
Result:
VAR: Replace fixed.
("Xyfixed" replaced with "fixed" as expected.)
3.
//echo 12 -ag $regsub(Replace myfixed., /myfixed/, fixed, %var) | echo 12 -ag VAR: %var
Result:
("myfixed" replaced with "fixed" as expected.)
As seen above, surrounding the regular expressoin with /'s does avoid the issue.
I'm assuming it is related to the "m" in this:
"The $ prefix
Indicates that the matchtext section of a definition contains a regular expression.
on $*:TEXT:m/regular expression/switches:#:/echo message: $1-
The m and the switches are optional. The // are required. If switches are used they must be standard PCRE switches, otherwise the match will fail. You can use switch S to strip control codes from $1-."
Though the requirement above is not stated for regular expression outside of events, unless I missed it. (Quite possible).
(BTW, what does the "m" prefix do? Probably something else I've missed.)
Thank you for your time.
1.
//echo 12 -ag $regsub(Replace myfixed., myfixed, fixed, %var) | echo 12 -ag VAR: %var
Result:
VAR: Replace myfixed.
(myfixed replaced with "myfixed" instead of "fixed".)
2.
//echo 12 -ag $regsub(Replace Xyfixed., Xyfixed, fixed, %var) | echo 12 -ag VAR: %var
Result:
VAR: Replace fixed.
("Xyfixed" replaced with "fixed" as expected.)
3.
//echo 12 -ag $regsub(Replace myfixed., /myfixed/, fixed, %var) | echo 12 -ag VAR: %var
Result:
("myfixed" replaced with "fixed" as expected.)
As seen above, surrounding the regular expressoin with /'s does avoid the issue.
I'm assuming it is related to the "m" in this:
"The $ prefix
Indicates that the matchtext section of a definition contains a regular expression.
on $*:TEXT:m/regular expression/switches:#:/echo message: $1-
The m and the switches are optional. The // are required. If switches are used they must be standard PCRE switches, otherwise the match will fail. You can use switch S to strip control codes from $1-."
Though the requirement above is not stated for regular expression outside of events, unless I missed it. (Quite possible).
(BTW, what does the "m" prefix do? Probably something else I've missed.)
Thank you for your time.