Re: extract variables from expression




<alexjaquet@xxxxxxxxx> wrote in message
news:1146314371.196741.78670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

Does somebody know how to extract some variables from this expression :

[quote=alexandre]Ceci est un testttttt[/quote]

I want to extract the values alexandre and the text "Ceci est un test"
and I can have multiple quoted expression :
[quote=alexandre]Ceci est un testttttt[/quote]
[quote=tester]response[/quote]


Assuming no nested quotes and the data is always as simple as the above:

while (my $line = <DATA>) {
if ($line =~ m#\[([^\]]+)](.*?)\[/quote]#) {
my $speaker = (split(/=/, $1))[1];
my $quote = $2;
}
}

__DATA__
[quote=alexandre]Ceci est un testttttt[/quote]
[quote=tester]response[/quote]



.



Relevant Pages

  • Re: extract variables from expression
    ... Does somebody know how to extract some variables from this expression: ... I want to extract the values alexandre and the text "Ceci est un test" ... Assuming no nested quotes and the data is always as simple as the above: ...
    (comp.lang.perl.misc)
  • extract variables from expression
    ... Does somebody know how to extract some variables from this expression: ... I want to extract the values alexandre and the text "Ceci est un test" ...
    (comp.lang.perl.misc)