mabog Posted September 28, 2010 Share Posted September 28, 2010 Preg matching is killing me... $string1="Here: http://www.example.com"; $string2="Here: http://www.example.com check that."; How can I match that address only in both cases? I have this: preg_match_all("/[hH][tT][tT][pP]\:\/\/.*\s/",$string,$matches); print_r($matches); Which matches only string 2 AND with a space at the end. And this: preg_match_all("/[hH][tT][tT][pP]\:\/\/.*.(\s|\b)/",$string,$matches); print_r($matches); Which matchs both BUT with "check that" text at the end! Is the trick to match that link as one word? How? Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 28, 2010 Share Posted September 28, 2010 Not perfect, but try: preg_match_all("#http://[^\s]+#i", $string, $matches); Quote Link to comment Share on other sites More sharing options...
mabog Posted September 28, 2010 Author Share Posted September 28, 2010 Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.