Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 imbibing at the Monastery: (4)
As of 2021-01-18 02:20 GMT
Find Nodes?
    Voting Booth?