Javascript replace by regex but only the first character -


i want replace spaces in string in javascript. if there price behind it.

example:

var before = 'porto rood / wit 4,00'; var after = 'porto rood / wit;4,00'; 

the regex use \s\d+,\d{2}

in javascript there way replace first character of regex match ?

you can use positive lookahead match whitespace before price.

var before = 'porto rood / wit 4,00',      after = before.replace(/\s(?=\d+,\d{2})/, ';');      console.log(after);


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -