I'm basically doing this, replace a with nothing, then b with nothing:
RegExReplace(testVar,"a|b","")
(?<= ) +
This uses a look-behind assertion. Replace one or more spaces if preceded by a space (the preceding space is not replaced).
Regular Expressions (RegEx) - Quick Reference
https://autohotkey.com/docs/misc/RegEx-QuickRef.htm
Look-ahead and look-behind assertions: The groups (?=...), (?!...), (?<=...), and (?<!...) are called assertions because they demand a condition to be met but don't consume any characters.
[" Chr(1) "-" Chr(31) "\\/:*?""<>|]
This is a character class, replace any character that matches one of these characters. Character classes have certain characters with a special meaning, e.g hyphen, to indicate a range:
"a-z" is the same as
Chr(97) "-" Chr(122).
One wonders about how RegEx works behind the scenes, these work for example:
Code: Select all
MsgBox, % RegExReplace("abababab", "a|b", "") ;result is blank)
MsgBox, % RegExReplace("CababCDCDababD", "D|a|b|C", "") ;result is blank
MsgBox, % RegExReplace("CababCDCDababD", "D$|a|b|^C", "") ;result is CDCD ;^ and $ are anchors