Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

preg_match, to match URL in email.

  •  01-24-2009, 4:29 PM

    preg_match, to match URL in email.

    Hi,

     I'm using PHP to parse an incoming email. I wish to be able to match then store URL's contained in the email message.

    I just need to figure out the RegEx to match URL's.  I've been currently building and testing this:

    (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?

    and 

    /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/gi

    On this site.  http://gskinner.com/RegExr/

    But it's not working when I actually put it to use. I get errors like ... 

    preg_match() [function.preg-match]: Unknown modifier '~' in /index.php on line 427


    My only only secondary piece of this puzzle is that most emails will have more then one URL, so my second task was to make sure the RegEx could see more then one match...



    Any help is Greatly appricated.

    Thanks!

     


View Complete Thread