Regular Expression To Get The Number At The End Of A String

A regular expression that matches the number at the end of a string (also called trailing numbers).

I am sure you have had a time when you needed the number at the end of a string of characters. Perhaps it was a long username and you needed to parse out the last x numbers or maybe you were parsing a parameter but needed to get rid of the index number. Well, if this is something you deal with on a regular basis, then take a look at this little snippet to make your life easier.



  • RegexPattern123
  • Word345
  • 789


  • Regex123Pattern
  • Word345 Word
  • Abcd

See Also: