Was playing around with regexp to remove all numbers from string
I came up to this:
/([^0-9])$/
But it works only if string looks like this, e.g. Name123 but if you enter Name123Name than it doesn’t work?
Can’t understand why?
Any ideas?
Best regards,
Ilia
Your regular expression finds one character not in
[0-9]at the end of the string.To check if there is a digit anywhere in the string, remove the anchors:
To check that all characters are not digits, add a start of string anchor too:
This approach is called a blacklist – a list of characters you don’t want to allow. Note that it’s often better to create a whitelist instead – a list characters that you do want to allow.