CGhoST
(John)
1
Hi Everyone,
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]”, “”)
Please help.
1 Like
Hey @CGhoST
You can please go with normal String Replace
method.
str_OriginalText.Replace(str_DynamicText, String.Empty)
Hope this helps
Thanks
#nK
Yoichi
(Yoichi)
3
Hi,
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", "")
Regards,
System.Text.RegularExpressions.Regex.Replace(strVariable1, "("+strVariable2+")", "")
e.g.
system
(system)
Closed
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.