SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ignore link in certain format - regex

    Hi regex masters!


    Having this regex expression
    /((http(s?):\\/\\/{1}\S+))/
    it allows to fetch a link from a text string

    PHP Code:
    $string 'asdsa asdsa http://www.google.com asdasd';
    // link to be fetched by the regex

    $pattern '/((http(s?):\\/\\/{1}\S+))/';
    preg_match($pattern$string$match); 


    However, I would like to improve it in order to igonore the following link in $string = '[abc](http://www.google.com "def")'


    PHP Code:
    $string '[abc](http://www.google.com "def")';
    // link to be IGNORED by the regex

    $pattern '/((http(s?):\\/\\/{1}\S+))/';
    preg_match($pattern$string$match); 

    Many thanks

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    So you want to ignore any links inside of parenthesis?

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Kyle,

    Thanks for your reply.
    Ignore the links inside this expression

    [abc](http://url.com "text")

    Something like ignoring this... but fetching the other links
    PHP Code:
    (\\[.*\])\\(((http(s?):\\/\\/{1}\S+)) \\"(.*)\\"\\) 


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
  •