tags:

views:

96

answers:

1

I put 10 digit mobile numbers in a Textarea like the follwoing. 242452354643663463636346366363463636365636363634656346 but i need to put comma(,) after every 10 digit number.

+7  A: 

Like this?

"242452354643663463636346366363463636365636363634656346".replace(/(\d{10})/g,"$1,")

// 2424523546,4366346363,6346366363,4636363656,3636363465,6346
S.Mark
Yes like that..Which javascript event would be better we prefer Keyup?
Hari kanna
can u explain in detail?what is g?what is $1?
Hari kanna
@Hari kanna, `/(\d{10})/` is a [regular expressions](http://www.regular-expressions.info/), with 10 continuous digits, and `$1` means, matched 10 digits in the bracket `(` 10 digits `)`, add comma after all matched instances. Basically, replacing 10 digits with 10 digits + ","
S.Mark
http://xkcd.com/208/ ... I find you regexp people to be magical. +1
ItzWarty