can anyone please tell me how to remove the last numbers before the space using Regular Expression in javascript
ABCD 154 => ABCD
ACR 15 => ACR
SA 12S 8945 => SA 12S
Use the end of string $
anchor to replace the preceding space and numbers that follow at the end of the string.
str = str.replace(/ [0-9]+$/, '');
If you want to retain the space character, just remove it from the regular expression.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments