The Un-Official Proxomitron Forum
[solved] Negative regex / subdomain - Printable Version

+- The Un-Official Proxomitron Forum (https://www.prxbx.com/forums)
+-- Forum: Forum Related (/forumdisplay.php?fid=37)
+--- Forum: Archive (/forumdisplay.php?fid=50)
+---- Forum: BFilter (/forumdisplay.php?fid=41)
+----- Forum: Filters (/forumdisplay.php?fid=33)
+----- Thread: [solved] Negative regex / subdomain (/showthread.php?tid=1621)



[solved] Negative regex / subdomain - anewuser - May. 30, 2010 12:29 AM

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>/



RE: Negative regex / subdomain - anewuser - May. 30, 2010 01:01 PM

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


RE: Negative regex / subdomain - Graycode - May. 30, 2010 01:09 PM

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!