Home > Mobile >  How does the regular expression should be like for 0.(0)?
How does the regular expression should be like for 0.(0)?

Time:03-23

I have to check the string if it is like as 0.(0).
String such as 0.0, 0.00, 0.000, 0.0000, ...
The check result of these kinds of strings should be true.
I am going to use regex for checking that string, but I am not good at regex. I used regex pattern like below, but it doesn't work.

const pattern = /0.([0])/
return pattern.test('0.000') // this return value should be true.

How does the regex should be like?

CodePudding user response:

Please check this regex.

/^0\.0 $/

It works on my end. Let me know if it works or not.

CodePudding user response:

If it's only for zeros:

/0\.0 /
  • Related