I would like to a regular expression to use with javascript replace function that separe with a space each 2 number I type
Input Ex.: 01020304050607
Output Ex.: 01 02 03 04 05 06 07
How could I do it?
/(\\d{2})/g
should do the trick. Example:
> "021651984984984984".replace(/(\d{2})/g, "$1 ").trim()
"02 16 51 98 49 84 98 49 84"
Something like this?
var numbers = "0203040506";
var numbersString = numbers.replace(/([0-9]{2})(?=.)/g,"$1 ");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.