Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  23] [ 4]  / answers: 1 / hits: 66880  / 13 Years ago, thu, september 29, 2011, 12:00:00

I would like a regular expression or otherwise some method to remove the last character in a string if and only if that character is '/'. How can I do it?


More From » regex

 Answers
50
string = string.replace(//$/, );


$ marks the end of a string. / is a RegExp-escaped /. Combining both = Replace the / at the end of a line.


[#89857] Tuesday, September 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gerardamosy

Total Points: 600
Total Questions: 116
Total Answers: 102

Location: Ukraine
Member since Tue, May 30, 2023
1 Year ago
;