Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34758

Re: Using regexes versus "in" membership test?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.unit0.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'parsing': 0.07; 'subject:test': 0.07; 'pointers': 0.09; 'received:mail- vc0-f174.google.com': 0.09; "wouldn't": 0.11; 'dec': 0.15; 'discarded': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'phase,': 0.16; 'subject:versus': 0.16; 'wrote:': 0.17; 'instance,': 0.17; 'module,': 0.17; 'thu,': 0.17; 'trying': 0.21; 'parse': 0.22; 'strip': 0.22; "i'd": 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'skip:[ 10': 0.26; 'possibly': 0.27; 'possible,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'all.': 0.28; 'received:209.85.220.174': 0.29; "i'm": 0.29; 'function': 0.30; 'error': 0.30; 'figure': 0.30; 'info': 0.32; 'to:addr:python-list': 0.33; 'presence': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'subject:" ': 0.36; 'test': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'more': 0.63; 'percent': 0.65; 'message"': 0.84; 'quicker': 0.84; 'subject:Using': 0.84; 'victor': 0.84; 'subject:membership': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=yTJSL8/TPGOHqBLTRNvK10f174l2Wabbe9HcZhGV0Ms=; b=DCogtzP1DhK9TS2u7Kpih/RclSoTO5iaZMdxZ34CX4ytHQvHlSstZEZGYIN8JgNwFP MAuh2C82M8E/Iwk7s4Cyv6jPi/Nw4Kwc2+nCS+u390lV1WVpzbWVWw/xL7xZoK2gkilH fQKCbsQHkL3fKFYkNpSlaaTizoosjizP0tr+1Q/L5vTQ6Fu+xlp7cNOAU2Oq0L8ogQog NFbkYYU7fvI0oZ0YecYOmVR4tRyQ9/g+NjXRyXVp1Ve83sMux81WdzBnuiY+H/8s2HbB sA/cw2AdMdgY+HtBCgLA74tX8KYMheGxFQgerRCybGh0ihi1z+6kM4PMWt/a9WCCRgWg 8bHQ==
MIME-Version 1.0
In-Reply-To <a56c17dc-271e-44c7-bc3f-246366383817@googlegroups.com>
References <56f4fbf5-36e6-40d0-b832-e29f8a67190b@googlegroups.com> <50c92acd$0$29972$c3e8da3$5496439d@news.astraweb.com> <a56c17dc-271e-44c7-bc3f-246366383817@googlegroups.com>
Date Thu, 13 Dec 2012 17:19:57 +1100
Subject Re: Using regexes versus "in" membership test?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.822.1355379600.29569.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1355379600 news.xs4all.nl 6852 [2001:888:2000:d::a6]:37798
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34758

Show key headers only | View raw


On Thu, Dec 13, 2012 at 5:10 PM, Victor Hooi <victorhooi@gmail.com> wrote:
> Are there any other general pointers you might give for that regex? The lines I'm trying to match look something like this:
>
>     07:40:05.793627975 [Info  ] [SOME_MODULE] [SOME_FUNCTION] [SOME_OTHER_FLAG] [RequestTag=0 ErrorCode=3 ErrorText="some error message" ID=0:0x0000000000000000 Foo=1 Bar=5 Joe=5]
>
> Essentially, I'd want to strip out the timestamp, logging-level, module, function etc - and possibly the tag-value pairs?

If possible, can you do a simple test to find out whether or not you
want a line and then do more complex parsing to get the info you want
out of it? For instance, perhaps the presence of the word "ErrorCode"
is all you need to check - it wouldn't hurt if you have a few percent
of false positives that get discarded during the parse phase, it'll
still be quicker to do a single string-in-string check than a complex
regex to figure out if you even need to process the line at all.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Using regexes versus "in" membership test? Victor Hooi <victorhooi@gmail.com> - 2012-12-12 14:35 -0800
  Re: Using regexes versus "in" membership test? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-13 01:09 +0000
    Re: Using regexes versus "in" membership test? Victor Hooi <victorhooi@gmail.com> - 2012-12-12 22:10 -0800
      Re: Using regexes versus "in" membership test? Chris Angelico <rosuav@gmail.com> - 2012-12-13 17:19 +1100
        Re: Using regexes versus "in" membership test? Victor Hooi <victorhooi@gmail.com> - 2012-12-12 22:35 -0800
          Re: Using regexes versus "in" membership test? Chris Angelico <rosuav@gmail.com> - 2012-12-13 17:38 +1100
        Re: Using regexes versus "in" membership test? Victor Hooi <victorhooi@gmail.com> - 2012-12-12 22:35 -0800

csiph-web