Tõnis Palmipuu
Tõnis Palmipuu

Reputation: 41

C# Regex match commas and decimals

I am trying regex to match decimals and commas. Code will take Bitcoin wallet account balance from API, what example would be 0.003827385, How could regex match number like that?

Upvotes: 1

Views: 6542

Answers (2)

Ashkan Mobayen Khiabani
Ashkan Mobayen Khiabani

Reputation: 34160

this should do it:

 Regex.Match(SearchString,"[0-9]+\.?[0-9,]*");

https://regex101.com/r/fP5jI7/2

Upvotes: 5

unlimit
unlimit

Reputation: 3752

Why don't you just try a regex to match decimals?

([\d+[,\d]*]*\.\d+)|[\d+[,\d]*]*

Your question is not clear about usage of commas. Note the above regex will not match commas after decimal point.

Upvotes: 0

Related Questions