Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verifying Email address

Status
Not open for further replies.

foobar2k

Technical User
Aug 3, 2000
3
GB
i want to add functionality to my script to check if $input{'email'} is in a valid email format (<A HREF="mailto:name@host.doma">name@host.doma</A>in).<br>Is this possible?<br>thanks<br>foobar2k
 
This may not be a perfect heuristic, but:<br><br>if ($address =~ /^([\w\-_\.]+)@(([\w\-_]+)\.)+([\w]+)$/) <br>{<br>&nbsp;&nbsp;print &quot;This is probably an email address&quot;;<br>}<br>else<br>{<br>&nbsp;&nbsp;print &quot;This is definitely not an email address, loser.&quot;;<br>}<br><br>Sincerely,<br><br>Tom Anderson<br>CEO, Order amid Chaos, Inc.<br><A HREF=" TARGET="_new">
 
thanks, the code seems to work fine<br>also is there any way to also verify that the field $input{'url'} begins with http:// ?<br>thanks <br>foobar2k
 
I suggest you learn how to write your own regular expressions.&nbsp;&nbsp;You can't keep asking people to come up with them for you.&nbsp;&nbsp;How will you know if they are correct or not?&nbsp;&nbsp;There are plenty of sources on the web, just do a search.<br><br>Sincerely,<br><br>Tom Anderson<br>CEO, Order amid Chaos, Inc.<br><A HREF=" TARGET="_new">
 
The best way to learn is by example, and correct me if i am wrong but is this a technical help forum?<br>If you dont want to help then dont, but otherwise dont criticise the questions.
 
I didn't mean to criticize but it's not that hard to learn.&nbsp;&nbsp;I think you will find that tutorials are more helpful than just asking someone to do it for you.<br><br>for the http, try this:<br><br>sub check_http<br>{<br>&nbsp;&nbsp;my ($url) = @_;<br>&nbsp;&nbsp;if ($url =~ /^http:\/\/(.*)$/) {return 1;} else {return 0;}<br>}<br><br>Sincerely,<br><br>Tom Anderson<br>CEO, Order amid Chaos, Inc.<br><A HREF=" TARGET="_new">
 
foobar -- people give their own time to help you and me in these forums <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top