Zack Shapiro
Zack Shapiro

Reputation: 6998

Bug in my regular expression

I'm trying to look at a string and reject anything that has seq= or app= in the string. Where it gets tricky is I need elements with q=something or p=something.

The seq= part of the string is always preceded an & and app= is always preceded by a ?

I have absolutely no idea where to start. I've been using http://www.rubular.com/ to try and figure it out but to no avail.

Any help would be hugely appreciated.

Upvotes: 0

Views: 75

Answers (1)

Tarwn
Tarwn

Reputation: 1030

Based on your question, I believe you could just reject any strings that match the following expression:

[\?&](?:seq|app)=

This will match any string that contains a ? or & followed by either app= or seq=. The ?: inside the parentheses just tells the regular expression not to bother to capture matching groups as sub-matches. They're not really necessary, but what the heck.

Here's a Rubular link with some samples.

Upvotes: 2

Related Questions