|  | 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
  Navigation: [Reply to this message] |