I'm a beginner in those regular expressions and s/// operations. How
can I extract only the digits and the periods (.) from a string ? I have
something like 206.48.16.3/12345. An IP address with a port number. There
are digits on both sides of the slash, but I would like to keep only the
digits from on the left as well as the periods. More complex question: If I
have something like "src=206.48.16.3/12345", how can I do the same as bove,
but also removing the "src=" at the beginning ?

        Thanks :-)

Jean-Francois Messier
Ottawa, CANADA

-----Original Message-----
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 05, 2001 11:18 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: Confirmation...


On Dec 6, Daniel Falkenberg said:

>$string =~ s/[^a-zA-Z0-9]//g;
>
>I take it only allows $string to eq anthing in the charcter class of
>a-z, A-Z and 0-9.  I also take it that anything other than that will be
>stripped out?  Any other comments?

Right.  I'd write it as

  s/[^a-zA-Z0-9]+//g;

for "efficiency".  Or perhaps as

  tr/a-zA-Z0-9//cd;

for "clarity".  Your ideas of "efficiency" and "clarity" may differ.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to