Gaz Smith
Gaz Smith

Reputation: 1108

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?

Upvotes: 0

Views: 40

Answers (1)

NoobDEV-GBL
NoobDEV-GBL

Reputation: 352

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)

Upvotes: 1

Related Questions