I’m looking for a regex pattern that given 1234
, returns 1,234
and given 1234.1234
, returns 1,234.1234
.
I’m using JavaScript and am using this pattern for an input on the website with real-time data entry.
I’m looking for a regex pattern that given 1234
, returns 1,234
and given 1234.1234
, returns 1,234.1234
.
I’m using JavaScript and am using this pattern for an input on the website with real-time data entry.
2
Answers
dot
if exists.comma
s.You can use a regexp