Reply to Help with regex

Your name:

Reply:


Posted by Mikkel Z. Herold on 01/10/07 23:45

Hi.

I have a problem with a regex - I hope someone here can help (though
strictly speaking it is not a php issue):

I have this regex that I use to check the syntax of URLs:

^((ht|f)tps?://)((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)$

I need to modify it, so that it accepts URLs with an "@" in them, such
as http://person.au.dk/da/dekan.hum@au.dk.

I have tried this

^((ht|f)tps?://)((([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-@]*)*)$

and that accepts URLs with @, BUT it rejects all other well-formed URLs!

As you can tell, I don't know much about regex'es, and the above is one
I have cut'n'pasted. Hope someone can help me out.

This message is X-posted to alt.php. FUT to alt.comp.lang.php

Mikkel

--
"At first just a rustle of canvas
And the gentlest breath on my face
But a galloping line of white horses
Said that soon we were in for a race"
Sting - The Wild Wild Sea

www.mzh.dk

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация