regular expression for email id and IP address
------_=_NextPart_001_01CBF6E1.AE5E32FF
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi All
1. Can anybody guide me to write a regular expression to
verify correct Email address ?
2. I have written a regular expression to verify correct IP address :
print $ipadd if ($ipadd =3D~
/^([0-9])|([1-9][0-9])|([1-2][0-5][0-5])\.([0-9])|([1-9][0-9 ])|([1-2][0-
5][0-5])\.([0-9])|([1-9][0-9])|([1-2][0-5][0-5])\.([0-9])|([ 1-9][0-9])|(
[1-2][0-5][0-5])/);
It is working as per my input . Please let me know if it correct or not
..
Thanks
Sunita
------_=_NextPart_001_01CBF6E1.AE5E32FF--
Re: regular expression for email id and IP address
At 11:42 PM +0530 4/9/11, Sunita Rani Pradhan wrote:
>Hi All
>
>
>
>
>
> 1. Can anybody guide me to write a regular expression to
>verify correct Email address ?
peldoc -q valid "How do I check a valid mail address?"
>
>
>
>2. I have written a regular expression to verify correct IP address :
>
>
>
>print $ipadd if ($ipadd =~
>/^([0-9])|([1-9][0-9])|([1-2][0-5][0-5])\.([0-9])|([1-9][0- 9])|([1-2][0-
>5][0-5])\.([0-9])|([1-9][0-9])|([1-2][0-5][0-5])\.([0-9])|( [1-9][0-9])|(
>[1-2][0-5][0-5])/);
>
>
>
>It is working as per my input . Please let me know if it correct or not
>.
I don't believe it is correct. Does it match 167.249.0.0?
--
Jim Gibson
Jim [at] Gibson.org
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
RE: regular expression for email id and IP address
Yes it is matching 167.249.0.0 .
-Sunita
-----Original Message-----
From: Jim Gibson [mailto:jimsgibson [at] gmail.com]
Sent: Saturday, April 09, 2011 11:50 PM
To: Perl Beginners
Subject: Re: regular expression for email id and IP address
At 11:42 PM +0530 4/9/11, Sunita Rani Pradhan wrote:
>Hi All
>
>
>
>
>
> 1. Can anybody guide me to write a regular expression to
>verify correct Email address ?
peldoc -q valid "How do I check a valid mail address?"
>
>
>
>2. I have written a regular expression to verify correct IP address :
>
>
>
>print $ipadd if ($ipadd =3D~
>/^([0-9])|([1-9][0-9])|([1-2][0-5][0-5])\.([0-9])|([1-9][0- 9])|([1-2][0
-
>5][0-5])\.([0-9])|([1-9][0-9])|([1-2][0-5][0-5])\.([0-9])|( [1-9][0-9])|
(
>[1-2][0-5][0-5])/);
>
>
>
>It is working as per my input . Please let me know if it correct or not
>.
I don't believe it is correct. Does it match 167.249.0.0?
--
Jim Gibson
Jim [at] Gibson.org
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: regular expression for email id and IP address
--bcaec52c661fae270c04a080a55e
Content-Type: text/plain; charset=ISO-8859-1
use Regexp::Common qw/ net /;
$ip =~ /$RE{net}{IPv4}/;
--bcaec52c661fae270c04a080a55e--
Re: regular expression for email id and IP address
--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On 2011-04-09 23:53 +0530, Sunita Rani Pradhan wrote:
> Yes it is matching 167.249.0.0 .
But it's also matching things like "42". Feature?
Read about quantifiers, and also about the precedence of |.
--
- Olof Johansson
- www: http://www.stdlib.se/
- {mail,xmpp}: olof [at] ethup.se
- irc: zibri on Freenode/OFTC/IRCnet/...
--
--UugvWAfsgieZRqgk
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk2gqJ4ACgkQCPS7eH/A+7rR0QCeKwhTNSulLeTDcwT0T5mQ nV7r
WqgAn1LUwvPX2/nOjFVwlsjPzmpU53qy
=r/In
-----END PGP SIGNATURE-----
--UugvWAfsgieZRqgk--
RE: regular expression for email id and IP address
Hi Johan
You are right. Thanks for pointing out . Can you help me
getting it correct ?
Thanks
Sunita
-----Original Message-----
From: Olof Johansson [mailto:olof [at] ethup.se]
Sent: Sunday, April 10, 2011 12:13 AM
To: beginners [at] perl.org
Subject: Re: regular expression for email id and IP address
On 2011-04-09 23:53 +0530, Sunita Rani Pradhan wrote:
> Yes it is matching 167.249.0.0 .
But it's also matching things like "42". Feature?
Read about quantifiers, and also about the precedence of |.
--
- Olof Johansson
- www: http://www.stdlib.se/
- {mail,xmpp}: olof [at] ethup.se
- irc: zibri on Freenode/OFTC/IRCnet/...
--
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: regular expression for email id and IP address
--pvezYHf7grwyp3Bc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On 2011-04-10 01:40 +0530, Sunita Rani Pradhan wrote:
> Hi Johan
s/Johan/Olof/, but who keeps score?
> You are right. Thanks for pointing out . Can you help me
> getting it correct ?
Somebody already mentioned Regex::Common.
--
- Olof Johansson
- www: http://www.stdlib.se/
- {mail,xmpp}: olof [at] ethup.se
- irc: zibri on Freenode/OFTC/IRCnet/...
--
--pvezYHf7grwyp3Bc
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk2gwewACgkQCPS7eH/A+7q89gCgrS0AwtG4QKZYXSMRcX6d FtIQ
gFUAn2W9viWMAgd3sumgGiGBm0p42/nJ
=atbq
-----END PGP SIGNATURE-----
--pvezYHf7grwyp3Bc--
Re: regular expression for email id and IP address
On 09/04/2011 21:30, Olof Johansson wrote:
> On 2011-04-10 01:40 +0530, Sunita Rani Pradhan wrote:
>
>> You are right. Thanks for pointing out. Can you help me getting it
>> correct ?
>
> Somebody already mentioned Regex::Common.
Use the same module for email addresses:
use Regexp::Common qw/ net Email::Address /;
$possible_ip =~ /^$RE{net}{IPv4}\z/;
$possible_email =~ /^$RE{Email}{Address}\z/;
Rob
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/