Re: extract variables from expression
- From: "Matt Garrish" <matthew.garrish@xxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 09:23:55 -0400
"Matt Garrish" <matthew.garrish@xxxxxxxxxxxx> wrote in message
news:7pJ4g.4790$fx.440916@xxxxxxxxxxxxxxxxxxxxxxxx
<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];
I was going somewhere else with that code. It can be made much simpler and
reliable for this single case with the following:
if ($line =~ m#\[quote=([^\]]+)](.*?)\[/quote]#) {
my $speaker = $1;
my $quote = $2;
}
}
__DATA__
[quote=alexandre]Ceci est un testttttt[/quote]
[quote=tester]response[/quote]
.
- References:
- extract variables from expression
- From: alexjaquet
- Re: extract variables from expression
- From: Matt Garrish
- extract variables from expression
- Prev by Date: Re: share a session between two website
- Next by Date: Re: extract variables from expression
- Previous by thread: Re: extract variables from expression
- Next by thread: Re: extract variables from expression
- Index(es):
Relevant Pages
|