Hi,
Using regular expressions, I need to replace any text in the amount field preserving optional minus sign, commas and decimal points.
I am doing this with System.Text.RegularExpressions.Regex.Replace(Amount, “[^0-9,.]+”,“”)
But this is not preserving minus sign. Can you help?
Thank you,
1 Like
Hi
Try with this expression
System.Text.RegularExpressions.Regex.Replace(Amount, “[\-]”, “”)
Cheers @A_Learner
Hi @A_Learner ,
Can you share input and expect output?
regards,
can u share the input value !Additionally,try to add the minus sign in the regular expression using slash
You can try expression… So it will remove all the special characters
System.Text.RegularExpressions.Regex.Replace(Amount,“[^0-9]+“,””)
@A_Learner
Input: TOTAL AMOUNT -$1,161.09
Output: -1,161.09
Thank you,
System.Text.RegularExpressions.Regex.Replace(Amount,“[^0-9]+“,””)
@A_Learner … You can try with this
@A_Learner

Regex for the output u mentioned
(?<=TOTAL AMOUNT\s*)[-0-9$,.]+
It will replace all the characters expect the digits
@A_Learner
Updated the above to include minus sign. Working good. Many Thanks.
system
(system)
Closed
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.