How can it be that this regular expression also returns strings that have a _ underscore as their last character?
It should only return strings with alphabetical characters, mixed lower- and uppercase.
However, the regular expression returns: 'action_'
$regEx = '/^([a-zA-Z])[a-zA-Z]*[\S]$|^([a-zA-Z])*[\S]$|^[a-zA-Z]*[\S]$/';
The
[\S]will match everything that is not whitespace, including underscore.Also, your expression is very odd!
If you want a string that only contains letters, then use
^[a-zA-Z]*$or^[a-zA-Z]+$(depending on if blank is allowed or not).If you’re trying to do something else, you will need to expand on what that is.