http://qs321.pair.com?node_id=11122009


in reply to regex search for words with one digit

Digits are, in Perl regular expressions, word characters.

If you want to exclude digits, you can use character classes: Either those defined by POSIX (only if you don't have Unicode characters), or using Unicode properties in a recent Perl.

Here's a Unicode-aware example:

use strict; use warnings; my $text = "John P5ete Andrew Richard58 Nic4k Le7on5"; my @names = $text =~ /\b\p{Alphabetic}*\d\p{Alphabetic}*\b/g; print "@names\n";