Paul Beckett wrote:
>
> I would like to match multiple occurrences of the same pattern:
> /\'([a-z0-9]{32})\'/
> This could appear 0 - to many times on a line.
> I need the actual text match, not just the occurrence frequency.
> Any suggestions as to how I could catch these would be appreciated.

Hello Paul.

You have written the regex you need, except that you don't need to escape the
single quotes. (You did want /exactly/ 32 characters and no upper case letters?)
Just apply this with a global modifier, /g, to the string in question and you
will get a list of matches. In the code below, note that one data line is short
(31 characters) and one has a capital letter, so only three matches are found.

HTH,

Rob



use strict;
use warnings;

my $string = qq(
  'o1ram7uie3fw06dqsgxl5cj824hbz9tv'
  'mfykaeql0r38v56zo17tgi2p4nwdxbc'
  'i3on6a9j0xumws5ydqfrvg24bptk8hl1'
  'otc2bd3zmyfu1860g9wqrjshxlkn57pA'
  '3z1yaljfpdcqmi9go2r5ntk7wehs640v'
);

my @matches = $string =~ /'([a-z0-9]{32})'/g;

print "$_\n" foreach @matches;


OUTPUT

o1ram7uie3fw06dqsgxl5cj824hbz9tv
i3on6a9j0xumws5ydqfrvg24bptk8hl1
3z1yaljfpdcqmi9go2r5ntk7wehs640v


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to