mardi 31 mars 2015

javascript regex to replace space with a hyphen

I need a regex which should read a string :



  1. with a 1 to unlimited numbers (say upto 10)

  2. read a space in between

  3. with a 1 to unliimited numbers (say upto 10)


then replace the space in the string with a '-'


for ex: 123 456 should be replaced with 123-456.


there are no any other characters apart from numbers in the string.


Aucun commentaire:

Enregistrer un commentaire