I am trying to get RegExReplace to work for me, and I encounter a strange behavior:
MyString := "This is a little test. Why not?"
MyResult := RegExReplace(MyString, " (t.+)\.", "$1")
MsgBox, %MyResult%
This is the result:
This is the behavior I would have expected:
AHK's regex replacement seems to include all characters into the match that are not explicitly excluded by being in the Regex but outside a capture group. (Space (" ") and period (".") in this example.) Is that normal? Can I turn this off and make it behave like all other Regex engines?
It's fine for simple regular expressions like the above, but once it gets really complex I don't want to re-test all my expressions to see whether they work in AHK as well...
Does anybody have any experience with this in AHK?
Daniel
EDIT: I should have added that this is the way to make it work:
MyResult := RegExReplace(MyString, ".*(t.+)\..*", "$1")
I am not looking for the regular expression, I am wondering why AHK's Regex treatment is so unusual in this respect.
Generated Image Alt-Text
[edited by: Trados AI at 4:09 AM (GMT 0) on 5 Mar 2024]