1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help with RegEx

Discussion in 'Programming' started by nevetS, Jul 6, 2005.

  1. #1
    I'm relatively new to regular expressions, and I have a particular thing I want to do: Replace relative url's with absolute urls, but leave absolute urls alone.

    If my pattern is: /src="/
    It matches all img's and hrefs, but what I really want is:
    /src="/ except if the next four characters are "http"
     
    nevetS, Jul 6, 2005 IP
  2. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #2
    and of course I find my solution a few seconds later after trying to figure this out for a day...

    for those who are looking for a similar solution, you need a negative assertion:

    /src="/
    changes to:
    /src="(?!http)/
     
    nevetS, Jul 6, 2005 IP