at the end of your regex, replace .\d+$ by (?:\.\d+)?$

The dot . means any character and therefore needs to be escaped : \.

  • (?: start of non capturing group

  • \. literally a dot

  • \d+ followed by at least 1 digit

  • )? end of the capturing group, that should appears 0 or 1 time (with ?)

demo

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top