Regex Match For /

Hi Devs, pls can anyone help me with regex expression to match /, I have used in my code but it’s not getting / from for each row data

grafik
for a / we need to escape with backslash

Hi ppr, I am using this System.Text.RegularExpressions.Regex.Matches(r(“Column5”).ToString, “[1]*$”)(0).value.Trim but it’s not getting it, I have a row 10/01/22


  1. a-zA-Z!@#$%^&*()_+-={};':\|<>/? ↩︎

[1]*$”)(0).value


  1. a-zA-Z!@#$%^&*()_+-={};':\|<>/? ↩︎

just let us know what your sample input text what is the expected output. thanks

My sample input is 10/01/22, I am expected to check for each row if I can see the input with / or any special character or letter, if true replace the row with double 2.0

not clear

but same as mentioned above related to unescaping the slash

grafik
grafik

So to make it clearer, for each of the rows I should have only double data type in the the row but in case there is any other character not double data type, replace it with 2.0.Hope clearer, pls what’s the best solution to handle it.Regards

image

grafik
have a check if with a regex.IsMatch(strValue, "[^\d\.\,\n]+$")

otherwise it is maybe simpler to check for a valid number and if it is not matched then replace

grafik

same idea when e.g. shifting the strategy from regex to double.TryParse(…) check

1 Like

Thanks ppr.Regards

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