Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

doubt on assertion regex

by loki (Novice)
on Jan 20, 2010 at 15:32 UTC ( [id://818482]=perlquestion: print w/replies, xml ) Need Help??

loki has asked for the wisdom of the Perl Monks concerning the following question:

hi all, i have a doubt on this regular exp can anyone explain me clearly.. actualy i am trying to extract the multiple conditions inside while and if... am using perl 5.8.6 windows XP.......

my perl code sampled: my $count = 0; foreach my $condition (@conditions) { $count++; my ($open,$close) = $condition =~ /( (?: [(] | \s )* ) (.*) /msx; print "$open $count $close"; }

and my C code

while ( ( 1 condition A && 2 condition B )&& ( 3 condition C 4 condition D ) )

and am facing the problem when i have a while loop like this

while ( (condition A) && (condition B) )
my desired output has to be....
while ( 1 (condition A) && 2 (condition B) )
but it prints has...
while ( ( 1 condition A) && ( 2 condition B) )

can anyone help me with the regex pls to get my desired output?

Replies are listed 'Best First'.
Re: doubt on assertion regex
by Anonymous Monk on Jan 20, 2010 at 16:04 UTC
    You have print "$open $count $close"; and you state that you want the number to preceed the parenthesis.

    So use print "$count $open$close";

      no its wrong... it will print as
      while 1( 2(condition A)&& 3(condition B) )
      which is not desired....
        My code prints a space between the numeral and the opening parenthesis. Show what code you're actually using, because it's not the same.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://818482]
Front-paged by keszler
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-03-28 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found