A regular expression that allows you to match any numbers but the last x digits (last 4 digits in this regex) in a string.
/\d(?=\d{4})/g
Matches:
- 12345
- 123456
- r12345
Non-matches:
- 1234
- Regex 134
- Regex Pattern
See Also:
- Regular Expressions For 4 Or 6 Digits
- Regex To Match One Digit Number
- Regex To Match The Last Occurrence Of Characters In A String
- Regex To Match First Numbers In A String
- Regex To Match Last X Characters In A String