Hi, Sharan Basappa <[EMAIL PROTECTED]> asked: > I have a code snippet as follows: > > keyword id1 = a x b x c; > keyword id2 = c x d x e; > > I would like to extract strings "a x b x c" and "c x d x e". > I know I can loop through the code and extract the strings, > but is there a RE that can do this with a single statement.
You could do something like #!/usr/bin/perl -w use strict; my $code; { local $/ = undef; $code = <DATA>; } my( @matches ) = ( $code =~ m/^\s*keyword\s+id\d+\s*=\s*(.*?)\s*;\s*$/gm ); foreach my $match (@matches ){ print "$match\n"; } __DATA__ blah blah keyword id1 = a x b x c; blah keyword id2 = c x d x e; blah > As a side point - is there way to debug RE. Example, many a > times when we write an RE, it fails and requires fine tuning. > But it would be good to see how far was the RE was able to go > and at what point it bailed out. See http://www.weitz.de/regex-coach/ HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/