More Regex

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Damo

    More Regex

    Hi

    I was reading through someone else s code earlier and I came across
    this regex

    $regex = '%src="(?!http://)%';

    I cant figure out what it does. The ? is a greedy quantifier is it not
    and should be after http://............. or is that rubbish

    And what does the ! do . Cant find anything info about that.

    any help would be appreciated

  • Michael Fesser

    #2
    Re: More Regex

    ..oO(Damo)
    >I was reading through someone else s code earlier and I came across
    >this regex
    >
    >$regex = '%src="(?!http://)%';
    >
    >I cant figure out what it does. The ? is a greedy quantifier is it not
    >and should be after http://............. or is that rubbish
    The ? is used in many places for many different things. In combination
    with a ! like in this case it's called a negative lookahead assertion.



    So the regex above matches all src=", that are not followed by http://.

    Micha

    Comment

    Working...