Reputation: 645
I need a regex to return input string minus certain number of characters from end. Input string will be series of alphanumeric characters (minus space).
For example, when input string is ABC123456789 I want regex to return all but last 4 characters.
Please don't ask why I need a regex for this trivial requirement.
Upvotes: 1
Views: 40
Reputation: 785376
Not sure why substring won't work for you but if regex is must to use then use:
^(.*?)\w{4}$
And use captured group #1.
Upvotes: 1