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


Groups > comp.lang.python > #6536

Re: Weird problem matching with REs

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder7.xlned.com!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <bahamutzero8825@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'debug': 0.03; 'escape': 0.04; 'parser': 0.05; 'behave': 0.07; 'behavior.': 0.07; 'bits': 0.07; 'character,': 0.07; "shouldn't": 0.07; 'though.': 0.07; 'python': 0.08; '(it': 0.09; 'down,': 0.09; 'url.': 0.09; 'written': 0.14; 'am,': 0.14; 'broken': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'approach,': 0.16; 'code),': 0.16; 'differently,': 0.16; 'parser,': 0.16; 'resist': 0.16; 'simplified': 0.16; 'trimming': 0.16; 'url:revision': 0.16; 'html,': 0.19; 'simpler': 0.19; 'guess': 0.19; 'header:In-Reply- To:1': 0.21; "aren't": 0.22; 'subject:problem': 0.22; "wasn't": 0.22; 'code.': 0.22; 'code': 0.24; 'match': 0.26; 'example': 0.27; "i'm": 0.27; '(not': 0.28; 'problem': 0.28; 'keeps': 0.28; 'received:209.85.214': 0.28; 'solving': 0.29; 'matches': 0.29; "python's": 0.29; 'instead': 0.29; 'code,': 0.29; 'putting': 0.30; 'html.': 0.30; 'sun,': 0.30; 'whitespace': 0.30; 'it.': 0.31; 'supposed': 0.31; 'specifically': 0.31; 'andrew': 0.32; 'steven': 0.32; 'to:addr:python-list': 0.33; 'rather': 0.34; 'characters': 0.34; 'header:User-Agent:1': 0.35; "d'aprano": 0.35; 'message- id:@gmail.com': 0.36; 'probably': 0.36; 'uses': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; 'put': 0.37; 'think': 0.38; 'problem.': 0.38; 'but': 0.38; 'purposes': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'sometimes': 0.39; 'should': 0.39; 'received:209': 0.39; 'attempt': 0.39; 'containing': 0.39; 'goes': 0.39; 'rest': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'received:192.168.1': 0.40; 'almost': 0.60; 'more': 0.60; 'your': 0.60; 'piece': 0.63; 'show': 0.66; 'noise': 0.67; 'dealing': 0.69; 'relevant': 0.69; 'apologize': 0.72; 'endeavor.': 0.84; 'irrelevant': 0.84; 'match?': 0.84; 'rip': 0.84; 'give.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=OHlTPw+2fSIQnBM0g9XoN4vKqcNTNyw+Zw0gfQgyoF4=; b=OraWBMG0xIeoAKoQaRz2W5xCz5Uxt8b+iDwRSlEn0ttDy+r13GbJC9SIFJ4Bd4GRu9 9FiLgUXdBTxSO0GPyQaAaYk8HLS6VKocAwfQX85Rj0wzVwBRxu40TAyHDbCqx7412cB1 j1V3Hv1z+0TUvqIfzd5gesu240sGz1/A2dgNE=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=cMWJqkBiHWV/bFuFgOejYgpi1c6fZlFZvRp8XqhYAxr7suzKOY6kFiUdwRsWSfJuUj XLSacpeDW0c9nyNKc5YIavnCn6FtqgHLt/4CccLk/OyBKIpnueREuNjyvey6hwBi1F4d 0ckkKNHdkIwdHgrAqXW8jI+a8R1rdZGVZKrkU=
Date Sun, 29 May 2011 08:41:16 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5
MIME-Version 1.0
To python-list@python.org
Subject Re: Weird problem matching with REs
References <mailman.2220.1306669538.9059.python-list@python.org> <4de2459b$0$29996$c3e8da3$5496439d@news.astraweb.com>
In-Reply-To <4de2459b$0$29996$c3e8da3$5496439d@news.astraweb.com>
X-Enigmail-Version 1.1.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.2222.1306676482.9059.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 82.94.164.166
X-Trace 1306676483 news.xs4all.nl 49047 [::ffff:82.94.164.166]:48927
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6536

Show key headers only | View raw


On 2011.05.29 08:09 AM, Steven D'Aprano wrote:
> On Sun, 29 May 2011 06:45:30 -0500, Andrew Berg wrote:
>
> > I have an RE that should work (it even works in Kodos [1], but not in my
> > code), but it keeps failing to match characters after a newline.
>
> Not all regexes are the same. Different regex engines accept different 
> symbols, and sometimes behave differently, or have different default 
> behavior. That your regex works in Kodos but not Python might mean you're 
> writing a Kodus regex instead of a Python regex.
Kodos is written in Python and uses Python's regex engine. In fact, it
is specifically intended to debug Python regexes.
> Firstly, most of the code you show is irrelevant to the problem. Please 
> simplify it to the shortest, most simple example you can give. That would 
> be a simplified piece of text (not the entire web page!), the regex, and 
> the failed attempt to use it. The rest of your code is just noise for the 
> purposes of solving this problem.
I wasn't sure how much would be relevant since it could've been a
problem with other code. I do apologize for not putting more effort into
trimming it down, though.
> Secondly, you probably should use a proper HTML parser, rather than a 
> regex. Resist the temptation to use regexes to rip out bits of text from 
> HTML, it almost always goes wrong eventually.
I find this a much simpler approach, especially since I'm dealing with
broken HTML. I guess I don't see how the effort put into learning a
parser and adding the extra code to use it pays off in this particular
endeavor.
> > I was able to make a regex that matches in my code, but it shouldn't:
> > http://x264.nl/x264/64bit/8bit_depth/revision.\n{1,3}[0-9]{4}.\n{1,3}/
> x264.\n{1,3}.\n{1,3}.exe
>
> What makes you think it shouldn't match?
AFAIK, dots aren't supposed to match carriage returns or any other
whitespace characters.
> By the way, you probably should escape the dots, otherwise it will match 
> strings containing any arbitrary character, rather than *just* dots:
You're right; I overlooked the dots in the URL.

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


Thread

Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 06:45 -0500
  Re: Weird problem matching with REs Ben Finney <ben+python@benfinney.id.au> - 2011-05-29 23:00 +1000
    Re: Weird problem matching with REs Ben Finney <ben+python@benfinney.id.au> - 2011-05-29 23:03 +1000
    Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 08:29 -0500
  Re: Weird problem matching with REs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 13:09 +0000
    Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 08:41 -0500
      Re: Weird problem matching with REs Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 14:18 +0000
        Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 09:35 -0500
          Re: Weird problem matching with REs John S <jstrickler@gmail.com> - 2011-05-29 08:48 -0700
            Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 11:16 -0500
              Re: Weird problem matching with REs John S <jstrickler@gmail.com> - 2011-05-29 09:45 -0700
            Re: Weird problem matching with REs Chris Angelico <rosuav@gmail.com> - 2011-05-30 03:57 +1000
      Re: Weird problem matching with REs Roy Smith <roy@panix.com> - 2011-05-29 11:19 -0400
        Re: Weird problem matching with REs Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-29 10:31 -0500
          Re: Weird problem matching with REs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-29 21:06 +0200

csiph-web