Matching substring

Matching substring

am 14.11.2007 07:32:57 von M

Hi All

I have a string :

invokeEvent('5_290_act', true)" class="button">Add

I need to get 5_290_act into a variable, can you please tell me how to
construct regular expression for this.

Thanks
M

Re: Matching substring

am 14.11.2007 08:21:21 von Martijn Lievaart

On Tue, 13 Nov 2007 22:32:57 -0800, m wrote:

> Hi All
>
> I have a string :
>
> invokeEvent('5_290_act', true)" class="button">Add
>
> I need to get 5_290_act into a variable, can you please tell me how to
> construct regular expression for this.
>
> Thanks
> M

if (/invokeEvent\('(.*?)', true\)" class="button">Add/) {
$var = $1;
}

HTH,
M4

Re: Matching substring

am 14.11.2007 13:00:19 von Tad McClellan

m wrote:

> I have a string :
>
> invokeEvent('5_290_act', true)" class="button">Add


I'll assume the string is in the $_ variable.


> I need to get 5_290_act into a variable, can you please tell me how to
> construct regular expression for this.


my($var) = /(\d\w+)/;


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Re: Matching substring

am 15.11.2007 02:44:44 von Petr Vileta

m wrote:
> Hi All
>
> I have a string :
>
> invokeEvent('5_290_act', true)" class="button">Add
>
> I need to get 5_290_act into a variable, can you please tell me how to
> construct regular expression for this.
>
I assume that string is in variable $var

$var =~ s/^[^']+([^']+).+$/$1/;

or store to other variable without modify $var

$othervar = $1 if($var =~ m/^[^']+([^']+).+$/);

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: Matching substring

am 19.11.2007 13:50:49 von rvtol+news

m schreef:

> I have a string :
> invokeEvent('5_290_act', true)" class="button">Add
> I need to get 5_290_act into a variable, can you please tell me how to
> construct regular expression for this.

perl -Mstrict -wle'
my $string = qq{invokeEvent("5_290_act", true)"
class="button">Add};
my ($variable) = $string =~ m/(5_290_act)/;
print $variable;
'
5_290_act

--
Affijn, Ruud

"Gewoon is een tijger."