Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
112
rated 0 times [  113] [ 1]  / answers: 1 / hits: 37781  / 15 Years ago, wed, march 17, 2010, 12:00:00

I need some help. I am looking for a regex that would match the last space character in a string. I am using JavaScript and classic ASP.



I have a long string of text which I trim to 100 characters. I would like to remove the last character to avoid a spelling mistake if the trim cuts a word due to the 100 characters limit.



regex.replace(/[ ]$.*?/ig, '');


Anybody with ideas? Thanks.


More From » regex

 Answers
19

From my understanding, you need to remove the last space and everything after it, right?



 str = str.replace(/s+S*$/, )

[#97308] Monday, March 15, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kerryoliviaa

Total Points: 221
Total Questions: 102
Total Answers: 117

Location: Sint Maarten
Member since Tue, Mar 29, 2022
2 Years ago
;