Re: returning problem of regexp

2004-06-11 Thread Graf Laszlo
Hi Ziggy
You got me wrong. Anyway thanks for example.
Take a look here:
#!/usr/bin/perl
@str = ();
push @str, sm:a\n;
push @str, sm:b\n;
push @str, BBB\n;
push @str, /sm:b\n;
push @str, sm:cs\n;#- watch this line
push @str, sm:c no=\1\\n;
push @str, CCC1\n;
push @str, /sm:c\n;
push @str, sm:c no=\2\\n;
push @str, CCC2\n;
push @str, /sm:c\n;
push @str, /sm:cs\n;   #- and this line
push @str, /sm:a\n;#- and this line
my $i = 1;
for (@str) {
if ( /^(.*?)(sm:.+?)(.*?)$/ .. /^(.*?)(\/sm:.+?)/ ) {
print $_;
}
$i++;
}
wich returns these lines:
sm:a
sm:b
BBB
/sm:b
sm:cs  - the first watched line is present
sm:c no=1
CCC1
/sm:c
sm:c no=2
CCC2
/sm:c
 - the last two are missing from the end
What is wrong in regexp ?
Graf  Laszlo
Ziggy wrote:
On Thursday 10 June 2004 16:21, Graf Laszlo wrote:
Hi Jose
Thank you for your last reply. It did work.
But now I have to make some changes in my lines:
By example:
sm:a
sm:b
BBB
/sm:b
sm:cs
sm:c no=1
CCC1
/sm:c
sm:c no=2
CCC2
/sm:c
/sm:cs
/sm:a
As you can see, I put sm:cs wich means more sm:cs.
I prefer this form // .. // of regexp.
How should I change it to match all lines which contain 'sm:',
no matter of following characters ?
Graf Laszlo

This is a test program I made to understand regular expressions  search and 
replace.
invoke it -- ./leet string

I thought about changing it to add something with null or something... but I 
haven't finished it eversince then.

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



returning problem of regexp

2004-06-10 Thread Graf Laszlo
Hi Jose
Thank you for your last reply. It did work.
But now I have to make some changes in my lines:
By example:
sm:a
sm:b
BBB
/sm:b
sm:cs
sm:c no=1
CCC1
/sm:c
sm:c no=2
CCC2
/sm:c
/sm:cs
/sm:a
As you can see, I put sm:cs wich means more sm:cs.
I prefer this form // .. // of regexp.
How should I change it to match all lines which contain 'sm:',
no matter of following characters ?
Graf Laszlo
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



regexp

2004-05-19 Thread Graf Laszlo
Hi
I have the following HTML structure:
sm:a
sm:b
BBB
/sm:b
sm:c
CCC
/sm:c
/sm:a
Every line in this structure is an element of an array,
named @lines, and I access the elements using a foreach loop.
When I know the tag's name, by example 'sm:a',
and I need to extract the information contained by 'sm:a'
and '/sm:a' pair and the tags too, how should I proceed ?
I tried a regexp like this:
foreach $s (@lines) {
   print $s;
   if($s =~ m|^(sm:a\\n)(.*?)(\\n\/sm:a)$|s){
  ($l,$c,$r) = ($1,$2,$3);
  print OK\n;
  print l: '$l'\n;
  print c: '$c'\n;
  print r: '$r'\n;
   }else{
  print HEHE\n;
   }
}
Help me. Thank you.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response