Doug Fir
Doug Fir

Reputation: 21212

Google Analytics Regular Expressions

Kinda new to Rgeluar expressions and for the benefit of learning wanted to know how to do the following on one line:

page matching regular expression: .pdf/$

and page containing "somestring"

and page excluding "someotherstring"

I can obtain my desired output using the 3 rules above. My question is can I put all into one line using regular expression? So the first line would be something like:

page matching reg exp: .pdf/$ somestring+ (then regex for does not contain in GA) someotherstring

Is it possible to put all in a oner?

Upvotes: 0

Views: 227

Answers (1)

Bergi
Bergi

Reputation: 664434

Lookahead will help you to match multiple independent things in one expression, and even allows to require non-matching. In your case:

/^(?=.*somestring)(?!.*someotherstring).*\.pdf$/

Upvotes: 1

Related Questions