String Matching With Regular expression

Hello Guys,

I have a string(description of some issue) which i need to match from a pool of Keywords already provided. These pool of keywords have keywords like APO, PO, TO, \FINW:ADP_TO_SAP_CS9\020-RENAME-US34-TCAL-FILE-IN-ERP1, I am using regular expression ^PO which is exact match for PO but in Case of \FINW:ADP_TO_SAP_CS9\020-RENAME-US34-TCAL-FILE-IN-ERP1 there are several \ given it can be more than one also in this string, So it is not able to identify this as whole string and taking it as some kind of regular expression instead , Please help me to get a regex , So it can consider \FINW:ADP_TO_SAP_CS9\020-RENAME-US34-TCAL-FILE-IN-ERP1 as string and matches

If there are , while matching in regular expressions, you need to escape such patterns with a preceding .
For \FINW:ADP_TO_SAP_CS9\020-RENAME-US34-TCAL-FILE-IN-ERP1, your pattern should be Capture

For the pool of keywords, the pattern will be,

Hi Madhavi,

I am having \FINW:ADP_TO_SAP_CS9\020-RENAME-US34-TCAL-FILE-IN-ERP1 as Variable , So, I can not amend \ for every \, It is also a String
Lets say
So i am using as
regex= ^var.

Lets say you have stored the value in the variable strString.
try using strString.Replace("", ā€œ\ā€)

I would not recommend using the "\" character to escape. Instead use the built-in and much more functional Regex.Escape() method. I would recommend encasing any regex literals within Regex.Escape() whenever you are using regex in C#/VB.NET

Thanks for the heads up, I am using
System.Text.RegularExpressions.Regex.Replace(strString, ā€œ[^\w\d]+ā€, ā€œā€)


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.