1

I have a string that contains multiple '-'. I want to remove the all '-'. I tried the following way but it didn't work.

var str = "baa7f3b17ffc-4216-bfbc-8e9f70f26984"
var new_str = str.replace('-', '')

How can I remove or replace all the '-'? Is there any simple function for that?

Subho Ghose
  • 97
  • 1
  • 2
  • 13

1 Answers1

5

Remove globally and remove the second parenthesis

 var str = "baa7f3b17ffc-4216-bfbc-8e9f70f26984";
 var new_str = str.replace(/-/g, '');
 console.log(new_str);
Unbywyd
  • 856
  • 1
  • 4
  • 8