SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: preg_replace

  1. #1
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    preg_replace

    How would I adjust this:

    $find='/href="/';

    to ignore: href="http://

    but not: href="

    I tried this:

    $find='/href="(^http)/';

    Thanks E

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The following skips http:// and https:// urls.

    PHP Code:
    $pattern '#href="(?!https?://)([^"]+)"#si';
    if (
    preg_match_all($pattern$s$m))
    {
            
    $matches $m[1];
            
    print_r($matches);



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •