On Wed, Jul 9, 2008 at 9:22 AM, luke devon <[EMAIL PROTECTED]> wrote:
> Hi
> I am storing IP in to a varable ,  $ip="172.22.8.10 \-";
> but i wanted to filter out only the ip . how can i do that ? please help
> Thank you
> Luke

$ip =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
$ip = $1;

Or you can use [0-9] in place of \d to avoid catching the non-[0-9]
that \d includes. Though \d looks cleaner IMHO.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to