I got the following code (from this forum -- thanx!) to pull URL's out of a text string:

preg_match_all('/(http:\/\/|www.)[\s\'">]+/', $text, $matches);
$urls = $matches[0];

Now I can't quite get how to tweak it to skip over one particular URL (mine!).

Can someone please insert 'mysite.com' appropriately in the above expression to pull all URL's EXCEPT mysite.com.

    maybe try this:

    preg_match_all('/(http:\/\/|www\.)(?!www.\mysite\.com)(?!mysite\.com)[^\s\'">]+/', $test, $matches);
    
    
    

      Thanks, I'll give that a try (I'm away from my system for a few days so can't get to it immediately)

      Not sure about the '?!' - doesn't the ? go after the sequence, like (my.site.com)? and I thought ^ is the negation character, not !

      Anyway, you clued me into what might have been wrong with my own attempts -- I wasn't escaping the . in mysite.com

        Great, and thanks for that link. I had a few reg-ex tutorial pages, but didn't know the manual had a definitive explanation (though I guess it only makes sense that it would :p )

          The php docs are some of the best out there. You should bookmark php.net.

            Write a Reply...