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? Link to comment https://forums.phpfreaks.com/topic/214633-preg-matching-an-address/ 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); Link to comment https://forums.phpfreaks.com/topic/214633-preg-matching-an-address/#findComment-1116814 Share on other sites More sharing options...
mabog Posted September 28, 2010 Author Share Posted September 28, 2010 Thanks! Link to comment https://forums.phpfreaks.com/topic/214633-preg-matching-an-address/#findComment-1116823 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.