Skip to content

Remove defined symbol from string when more than 1 in javascript

I have a string which is sometimes £10.00 and sometimes ££10.00, this is dynamic. is there a way to remove one of the £ signs from the string if more than one exists?

Answer

You may need to replace if is more then one, so you may do somting like @mplungjan told:

str = '££££££10.000'
str2 = str.replace(/£+/g, "£")
console.log(str2)