I have a variable strVariable2 which is a dynamic variable.
I wish to use strVariable2 as a match and remove from strVariable1
I was trying the following regular expression but doesn’t work.
Text.RegularExpressions.Regex.Replace(strVariable1, “[\b”+strVariable2+“\b]”, “”)
You can please go with normal
String Replace method.
Hope this helps
Can you try the following expression to escape special characters of regex?
System.Text.RegularExpressions.Regex.Replace(strVariable1, "\b"+System.text.RegularExpressions.Regex.Escape(strVariable2)+"\b", "")
System.Text.RegularExpressions.Regex.Replace(strVariable1, "("+strVariable2+")", "")
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.