facebook has asked for the wisdom of the Perl Monks concerning the following question:
Hi all. I have a string that exists of words. Some of these words have numbers in them. those are the words i am looking for. This is what i came up with:
$names = "1Petrus2 Joh4an Smit 2johnny99 Julius 789"; while($names =~ /\b(\w*\d+\w*)\b/g){ print "$1\n"; }
this looks to be working. Can you tell me if this is the correct way or are there better ways?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: words with numbers in them
by Corion (Patriarch) on Jul 31, 2018 at 14:17 UTC | |
|
Re: words with numbers in them
by Paladin (Vicar) on Jul 31, 2018 at 18:52 UTC | |
by facebook (Initiate) on Jul 31, 2018 at 19:19 UTC | |
by tybalt89 (Monsignor) on Jul 31, 2018 at 20:58 UTC | |
by facebook (Initiate) on Aug 01, 2018 at 14:09 UTC | |
by tybalt89 (Monsignor) on Aug 02, 2018 at 01:35 UTC | |
|
Re: words with numbers in them
by BillKSmith (Monsignor) on Jul 31, 2018 at 14:50 UTC |