Detect value of 0 or 1

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Detect value of 0 or 1

Post by JAB Creations »

In AWStats you can set custom detection rules. One such rule I'm interested but needs regex modification is the HTTP query 'connection;' on my site (which has a value or 0 or 1). By default using this PERL regex it only detects if the value is '1'...

Code: Select all

ExtraSectionFirstColumnValues2="QUERY_STRING,connection=([^&]+)"
How do I include all numbers including '0'?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Detect value of 0 or 1

Post by Christopher »

That would be [^0-9]
(#10850)
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Re: Detect value of 0 or 1

Post by GeertDD »

arborint wrote:That would be [^0-9]
I'd invert that regex part. You do want to match the 0 or 1 while [^0-9] mathes anything that is *not* a digit.

So, make it [0-9] or \d or even [01].
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Detect value of 0 or 1

Post by JAB Creations »

Actually the issue was in AWStats as it was intentionally stripping zeros to avoid loops which I haven't encountered since commenting the line out. Thanks for replying!
Post Reply