Regex To Match Last X Characters In A String

A regular expression that can be used to get the last X (2, for example) characters of a string.

/.{2}$/g

Matches:

  • 123456
  • RegexPattern
  • Regex.us

See Also: