Reputation: 8405
The title pretty much explains it, I keep matching ga.src when I don't want to be, otherwise this is a great solution. Could someone tell me what is wrong?
Not working
~(?!.)\b(?:href|src)\s*=\s*(["\']?+)\K(?:/(?!/)|(?=[\s>]|\1))~i
Works but matches .src .href
~\b(?:href|src)\s*=\s*(["\']?+)\K(?:/(?!/)|(?=[\s>]|\1))~i
Upvotes: 2
Views: 67
Reputation: 14931
(?!.)
is a negative lookahead which checks if there is no character ahead (except for newline), which doesn't make sense. You want a lookbehind and the dot should be escaped (?<!\.)
.
Read about lookarounds on www.regular-expressions.info
Upvotes: 2