Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

JavaScript/REGEX: Remove Numbers from End of String

Using JavaScript, how can I remove all digits from the end of a string?

alert( zapTrailingNumbers('abc123')  ) // should be "abc"
alert( zapTrailingNumbers('abc123xyz')  ) // should be "abc123xyz"
alert( zapTrailingNumbers('abc0')  ) // should be "abc"
alert( zapTrailingNumbers('abc123xyz2')  ) // should be "abc123xyz"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
haha, snap!
Avatar of hankknight

ASKER

Wow, exactly the same answer only seconds apart!  Peer affirmed.  Thank you both.