Home > Software engineering >  How to use string with regex metacharacters as regex in replaceText?
How to use string with regex metacharacters as regex in replaceText?

Time:11-01

I have a bit of code that is searching a document for a tag and replacing it with a specific merge field. This code works fine until my tag has a | (pipe symbol) in it.

For some reason that makes the search only partially match. I suspect this has something to do with it thinking the variable I am passing is a regEx pattern and not a literal string, but I am unsure how to force it to be treated as a string. I use sample

After:

after

Reference:

  • Related