Skip to content
Advertisement

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?

Advertisement

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)
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement