! I am working with the replace method of VBA Regex and am wondering how many parameters it can take? I've seen the msdn page that gives lots of different options, but I'm unsure about which to use. Here's the link to that page: MSDN Page: Regex.Replace Method
I would like to be able to use backreferences and other VBA Regex in the 'replace with' parameter, if possible.
I'm currently only able to do this, for example (a literal text replacement)
RE6a = RE.Replace(strData, " ")
I would like to do this, for example:
RE6a = RE.Replace(strData, \s)
or
RE6a = RE.Replace(strData, \1 \3 \4)
How can I do this in VBA Regex?
Thanks for any help!
VBA does not have regular expressions. To use them, you have to reference a regex library first.
If it happened so that you referenced the Microsort VBScript Regular Expressions library, then you'll find the answer in the documentation:
' Swap first pair of words.
MsgBox(ReplaceTest("(\S+)(\s+)(\S+)", "$3$2$1"))