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
Post a Comment