1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

why is this regex not working? anyone with knowledge?

Discussion in 'White Hat SEO' started by wman5, Jun 12, 2016.

  1. wman5

    wman5 Newbie

    Joined:
    Apr 2, 2016
    Messages:
    6
    Likes Received:
    0
    hello,

    i have posts with the next structure:

    Code:
    [img]http://i.imgur.com/zIl6KWC.jpg[/img]
    
    description here
    imdb: http://www.imdb.com/title/tt2025690/
    
    urls:
    http://mylink.com/234234234
    http://mylink2.com/234234234
    http://mylin3k.com/234234234
    
    now i want a replace word function which will replace all urls in posts to google.com expect the image url. that one may not get changed.

    so i want it like:
    Code:
    [img]http://i.imgur.com/zIl6KWC.jpg[/img]
    
    description here
    imdb: http://www.google.com/title/tt2025690/
    
    urls:
    http://google.com/234234234
    http://google.com/234234234
    http://google.com/234234234
    
    so only domains must changed. not the image link.

    i use the next regex replace code, its working, but it also changes the domain of the image link and i dont want it:

    search for:https?://.+?/
    replace with: google.com
    enable regex

    can somebody please help? i want to use regex and replace all domains found in 1 single post, but it must not replace the image link. that one is mostly between
     
  2. ilikemoney9

    ilikemoney9 Newbie

    Joined:
    May 19, 2016
    Messages:
    10
    Likes Received:
    1
    Code:
    http:\/\/.+(?=\/(\d{9}|title))
    That seems to work in this specific example. I'm not sure if you needed something more flexible.

    You can then replace all those instances with 'http://google.com'.

    upload_2016-6-12_16-40-22.png