in reply to Check if a variable contains only one letter?
I can't believe everyone's missed the obvious!
$myvar =~ /X/i && $myvar !~ /[A-WYZ]/i
If you want to try putting it all in one regexp, see this meditation- Matching and nonmatching multiple regexps at once
And if you want it to be Unicode-safe, not just matching ASCII- I'm sure it can be and should be done, but I'm not the one to ask...
(edit #2) And if you really want to know if a string is a single letter X then don't use regexp. $myvar eq 'X'
|
|---|