I am using an regex expression where I need to remove special character from file name. I have used the below regex expression but it is removing the dot also. I want the dot in my file name .
System.Text.RegularExpressions.Regex.Replace(file_Name,"[^A-Za-z0-9 -]“,”")
(Before Regex)file_Name= 14638_Invoice.440992_1
After using regex file_Name = 14638_Invoice440992_1_
I want to keep the dot after Invoice in my file name .
With this corrected code, the regular expression [^A-Za-z0-9 .-] will match any character that is not a letter (uppercase or lowercase), digit, space, dot (. ), or hyphen (- ). This way, the dot in the file name will not be removed.
If i want to keep the brackets. This expression is removing the brackets .what will be the regex expression? In the below expression I need to keep the brackets