Tuesday 15 September 2015

I want to find numbers-include dot and comma- but Regex not working in javascript -



I want to find numbers-include dot and comma- but Regex not working in javascript -

i thought simple find out. how many ways tried still not work properly. below test snippet.

"100$ , 1.000,000eur 1,00.0.000usd .90000000000000000000$ (09898)".replace(/[\.,\d]*/g, '{n}')

and want result below.

{n}$ , {n}eur {n}usd {n}$ ({n})

the * problem, alter regex /[.,\d]+/g instead.

"100$ , 1.000,000eur 1,00.0.000usd .90000000000000000000$ (09898)".replace(/[.,\d]+/g, '{n}');

output

{n}$ , {n}eur {n}usd {n}$ ({n})

jsfiddle example check console screen output.

javascript regex

No comments:

Post a Comment