( Perl):
/\A.\z/s
\A " ", . " ", \z " ". \A \z .
Edit: But really you should do something like:
if( length($string) == 1 ) {
...
}
(using Perl as an example)
Edit2: I used to have one /^.$/, but, as Set pointed out, this allows matches of lines whose length is two characters, where is the last character \n. The design \A...\zcaptures this.
source
share