Post Reply 
[solved] Negative regex / subdomain
May. 30, 2010, 12:29 AM (This post was last modified: May. 30, 2010 01:02 PM by anewuser.)
Post: #1
Big Grin [solved] Negative regex / subdomain
Can somebody please help me with a regex that matches links to all Wikipedia domains but en.wikipedia.org? For example, I want to filter:
Code:
http://it.wikipedia.org/wiki/Lala
and
Code:
http://es.wikipedia.org/wiki/Lala
but not
Code:
http://en.wikipedia.org/wiki/Lala

I've tried this, but it didn't work:
Code:
/<a href="http://(?!en)\.wikipedia\.org/.*?".*?</a>/
Add Thank You Quote this message in a reply
May. 30, 2010, 01:01 PM
Post: #2
RE: Negative regex / subdomain
I've managed to do what I wanted by creating two filters. The first one adds an extra attribute to tags that contain links to en.wikipedia.org, and the second one matches all remaining Wikipedia links. Smile!

Code:
search="/<a href=\"http://en\\.wikipedia\\.org/"
replace=<<END
<a alt="WIN" href="http://en\.wikipedia\.org/
END
Code:
search=<<END
/<a href="http://..\.wikipedia\.org/
END

PS: I may have stripped something out while editing my code to post it here, but the full thing works. :p
Add Thank You Quote this message in a reply
May. 30, 2010, 01:09 PM (This post was last modified: May. 30, 2010 01:12 PM by Graycode.)
Post: #3
RE: Negative regex / subdomain
Great you were able to figure it out. I had a suggestion about whether or not you needed to escape the slashes, but apparently that was wrong. Good luck!
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: