[Israel.pm] match & expression Q.

Ernst, Yehuda yernst at ndsisrael.com
Sun Jul 18 00:15:51 PDT 2004


in your answer $var[0]$var[1]...will have the letters 
can i tell it to have the words like in my Q.

it should take the word until the first space.

so i get the answers like this
 $vars[0] = abc123
 $vars[1] = 12345

and not like this 
$vars[0] = a
$vars[1] = b


thanks yehuda.


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il]On
Behalf Of Gaal Yahas
Sent: Sunday, July 18, 2004 9:28 AM
To: Perl in Israel
Subject: Re: [Israel.pm] match & expression Q.


On Sun, Jul 18, 2004 at 09:19:09AM +0300, Ernst, Yehuda wrote:
> how do i write a line that will bring me 2 variables with the English and the numbers

You need a "character class" that contains English letters and numerals:

> שלום כיתה א ABC123 מה 12345 שלומכם היום 
> 
> the answer will be 
> $var1 = abc123
> $var2 = 12345

@vars = $string =~ /([0-9a-z])/gi;

"g" means match multiple times
"i" means case insensitive ("incasitive", to use Anatoly Vorobey's
    neologism); you could have used [0-9a-zA-Z] instead.

Your results will be in $vars[0], $vars[1], and so on.

-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl
***********************************************************************************
Information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the postmaster at nds.com and destroy the original message.
***********************************************************************************




More information about the Perl mailing list