Using Unicode or POSIX Character Classes
To verify that a string matches only alphanumeric text, you can use an attached character class. For instance:
Reinforcement is the main
The importance of reinforcing your expression cannot be overestimated. Without binding, the following would also be true:
"\nfoo" =~ /\p{Alnum}+/ "!foo!" =~ /\p{Alnum}+/
which is unlikely to be what you expect.
source share