Code: Select all
I'm amazed that it actually seems to work. Well, it seems
to be working correctly.
Bravo! You get an A+ for effort!
I can see some ways to simplify it - like replacing (?)+
, using only a single protocol (can you use just https, or is http necessary?), and there's no need to escape dots inside square brackets - but you've done an impressive job.
Also, I don't think that the trailing slash is necessary - I think allowedMimeRegExp just works with hostnames - but if it is, then /*
is wrong; it means 'zero or more slashes'. Maybe you meant /.*
(slash followed by zero or more arbitrary characters)?
My goal is to set up something that works per domain, is easy to "read" and to edit
Well, regex was not designed for its aesthetics...but you could separate out the various domains (chessgames.com, yahoo.com, etc) into separate rules, which might make it more readable, at the cost of having more duplication.
I tested the java regex on chessgames.com and at games.yahoo.com and it worked.
I can't test the silverlight regex right now because I don't have it installed (yet).
Fair enough. Are you sure that you'll want Silverlight? I don't have it installed, and never plan to.
HamptonHawes03 wrote:This forum didn't like the end of my post. In fact - I had to edit this post over and over to be able to get it to work.
Yeah, that happens a lot here, because the spam filter doesn't like links, and of course legitimate posts on this forum are full
If you really need to post something, just send it to a moderator via private message, and we can post it for you (we don't get filtered).
Is my regex designed correctly?
It looks pretty good, especially for someone who hates regex.
At games.yahoo.com the tab was sometimes empty before today. I think the problem was do to ads getting blocked. Now that I have a regex - If a site named annoying.com wants to run an ad - will my regex allow it? I actually want the answer to be "Yes." That way annoying.com can do its thing and noscript (or a[d]block) will stop me from seeing the annoyance anyway.
Actually, if it were to be allowed, then NoScript would not
block it - but yes, Adblock/ABP might.
But if the ad is coming from a third-party site, then the answer is "no". In my experience, though, things often still work.
OK, here's my attempt at a (slight) improvement on your regex:
Code: Select all
Note that I've put brackets around words when separated by |, because otherwise the | would apply only to single characters.