"Frank Geueke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi.  I need to grab regex matches from a string in
> perl.  The string is an enum data type in Mysql.  i.e.
> enum('Berks','Carbon','Lehigh','Montgomery')
> So basically I need a match on alphabetic chars
> between single quotes.  No problem.  But I'd like to
> be able to grab each match and store it in an array
> (in as few lines as possible).  I was told that split
> has an option that grabs delimiter matches instead of
> dropping delimiters and returning what's between them.
>  Any ideas?  Thanks.  Frank
>
Here is what I would use:

$ perl -mwarnings -mstrict
my $data = q|enum('Berks','Carbon','Lehigh','Montgomery')|;

my @vals = $data =~ m|'(.+?)'|g; # the expression you want

print( map "$_\n", @vals );
Ctrl-D
Berks
Carbon
Lehigh
Montgomery



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