Re: extract variables from expression
- From: "Matt Garrish" <matthew.garrish@xxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 10:37:34 -0400
<alexjaquet@xxxxxxxxx> wrote in message
news:1146319004.311639.205760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I made another test :
#!/usr/bin/perl -w
use strict;
my $line = " [quote=alexandre]Ceci est un
testttttt[/quote][quote=tester]response[/quote]";
open(DATA,">filename.txt");
print DATA $line;
close DATA;
open(DATA,"<filename.txt");
while ($line = <DATA>) {
if ($line =~ m#\[([^\]]+)](.*?)\[/quote]#) {
my $speaker = (split(/=/, $1))[1];
my $quote = $2;
print "$speaker\n";
}
}
close DATA;
and it's only print the first speaker
Once again, post context when replying.
You need to step back and learn some basic Perl first. But since you're
making at least some effort:
my $line = " [quote=alexandre]Ceci est un
testttttt[/quote][quote=tester]response[/quote]";
while ($line =~ m#\[quote=([^\]]+)](.*?)\[/quote]#gs) {
my $speaker = $1;
my $quote = $2;
print "$speaker\n";
}
Matt
.
- Follow-Ups:
- Re: extract variables from expression
- From: alexjaquet
- Re: extract variables from expression
- References:
- extract variables from expression
- From: alexjaquet
- Re: extract variables from expression
- From: Matt Garrish
- Re: extract variables from expression
- From: alexjaquet
- extract variables from expression
- Prev by Date: Re: extract variables from expression
- Next by Date: Module for a curses/Turbovision style interface
- Previous by thread: Re: extract variables from expression
- Next by thread: Re: extract variables from expression
- Index(es):
Relevant Pages
|