Last post Jul 15, 2017 02:19 AM by vinod_praviram
Jun 06, 2017 06:21 PM|vinod_praviram|LINK
I am in need to compare two strings.
I have list of strings and a separate string which needs to be compared with that list of strings.
Now the test string may contains some special characters like * or % where % represents zero or more occurrences of any chars.
Sample test string is like vinod file%.doc
which needs to be compared with
vinod file(1).doc - should match
vinod file.doc - should match
vinod file(1).pdf - should not match
vinod file.pdf - should not match
vinod prav file.doc - should not match
hello vinod file.doc - should match
Please tell me how I can achieve these results using simple regex or something similar.
Jun 06, 2017 06:57 PM|JBetancourt|LINK
first you need to escape your pattern like in:
var pattern =
var pattern = Regex.Escape("vinod file%.doc");
that will prevent interpreting your . as a regex special character
replace the % character with .*
so pattern will be:
then if you want to exclude .doc1 files finish your pattern with $
Jun 13, 2017 06:06 AM|JBetancourt|LINK
did that solved your issue?
Jul 15, 2017 02:19 AM|vinod_praviram|LINK
Thanks that simple regex worked perfectly