Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  183] [ 7]  / answers: 1 / hits: 43161  / 14 Years ago, fri, december 10, 2010, 12:00:00

To replace substring.But not working for me...



var str='------check';

str.replace('-','');


Output: -----check



Jquery removes first '-' from my text. I need to remove all hypens from my text. My expected output is 'check'


More From » javascript

 Answers
335

simplest:



str = str.replace(/-/g, ); 

[#94647] Wednesday, December 8, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josuea

Total Points: 609
Total Questions: 121
Total Answers: 104

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
josuea questions
;