Sharan Basappa wrote:
Hi,

Hello,

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.

It looks like /=\s+([^;]+)/g would match.


My first guess was to use /s modifier but I am not sure.

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.

You could use the (?{ code }) zero-width assertion to place print statements at certain points in the pattern printing out the contents of variables like $^N, $+, @- and @+, etc.

perldoc perlretut
perldoc perlre
perldoc perlvar




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to