Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: regex search for words with one digit

by haj (Curate)
on Sep 21, 2020 at 16:08 UTC ( #11122009=note: print w/replies, xml ) Need Help??

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";

Replies are listed 'Best First'.
Re^2: regex search for words with one digit
by AnomalousMonk (Bishop) on Sep 21, 2020 at 18:27 UTC

    Note that this matches the name '1'.

    Give a man a fish:  <%-{-{-{-<

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11122009]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-03-08 03:24 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (123 votes). Check out past polls.