Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parser': 0.05; 'predefined': 0.05; 'string,': 0.05; 'nasty': 0.07; 'python': 0.08; "(i'm": 0.09; 'all).': 0.09; 'backslash': 0.09; 'newline': 0.09; 'throw': 0.09; 'am,': 0.14; 'broken': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'library': 0.15; '(via': 0.16; 'capturing': 0.16; 'imo,': 0.16; 'parentheses': 0.16; 'looked': 0.16; 'suggest': 0.19; 'html,': 0.19; 'header:In- Reply-To:1': 0.21; 'variable': 0.21; 'subject:problem': 0.22; 'issues.': 0.23; 'changed': 0.25; 'match': 0.26; 'string': 0.26; 'work.': 0.28; 'received:209.85.214': 0.28; 'character': 0.29; 'matches': 0.29; 'true,': 0.29; 'code,': 0.29; 'bit': 0.30; 'config': 0.30; 'it.': 0.31; 'does': 0.33; 'to:addr:python-list': 0.33; 'lines': 0.33; "i've": 0.33; 'file': 0.34; 'header:User- Agent:1': 0.35; 'fixing': 0.35; 'message-id:@gmail.com': 0.36; 'quite': 0.36; 'received:google.com': 0.37; 'change': 0.37; 'received:209.85': 0.37; 'date,': 0.37; 'put': 0.37; 'two': 0.37; 'think': 0.38; 'could': 0.38; 'run': 0.38; 'but': 0.38; 'docs': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.38; 'case,': 0.39; 'should': 0.39; 'received:209': 0.39; 'containing': 0.39; 'feed': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'meaning': 0.40; 'really': 0.40; 'received:192.168.1': 0.40; 'more': 0.60; 'your': 0.60; 'john': 0.62; 'grab': 0.63; 'groups.': 0.65; 'composing': 0.84; 'grabbing': 0.84 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=Fs89L0atktffJE23DvyEJa8QWF+B1RYN8hlwwm/sUSM=; b=kPjsqFHhHotcWRHdImMVEFvOr1iWnRfvcR9PhhW1xQlkkvzAItQddJMW+1oYRBhDF2 1Vt0jtGAI1YlAL+JVdjreJgTfyJ2PnFP3e1MOAwpPCt9ZabmrYCT1lXott3aj8Lh/+Th dWdnSSpcV1bUlBCFSZf2NnqOVdddFyv8HDpI8= 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=DaAREmymINPtziguQvWRY1rY7UcjSdP5RTFe461aqHJ6o0qEKtojlTz3HjmimIjgqC cyPo310/YGckxU2evUwhWOVecxP+IGJKF/miWIHe1hsuKIhK/5Gf/TP5i0rXeMf4IC3X swvYo6KouhBE89SKhNc0uPYi43vorsBcx+RBU= Date: Sun, 29 May 2011 11:16:35 -0500 From: Andrew Berg 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: <4de2459b$0$29996$c3e8da3$5496439d@news.astraweb.com> <4de255a8$0$29996$c3e8da3$5496439d@news.astraweb.com> <1b8d81c1-ab87-4059-ad55-9f4a39331e7d@u26g2000vby.googlegroups.com> In-Reply-To: <1b8d81c1-ab87-4059-ad55-9f4a39331e7d@u26g2000vby.googlegroups.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306685804 news.xs4all.nl 49174 [::ffff:82.94.164.166]:42376 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6549 On 2011.05.29 10:48 AM, John S wrote: > Dots don't match end-of-line-for-your-current-OS is how I think of > it. IMO, the docs should say the dot matches any character except a line feed ('\n'), since that is more accurate. > True, malformed > HTML can throw you off, but they can also throw a parser off. That was part of my point. html.parser.HTMLParser from the standard library will definitely not work on x264.nl's broken HTML, and fixing it requires lxml (I'm working with Python 3; I've looked into BeautifulSoup, and does not work with Python 3 at all). Admittedly, fixing x264.nl's HTML only requires one or two lines of code, but really nasty HTML might require quite a bit of work. > In your case, and because x264 might change their HTML, I suggest the > following code, which works great on my system.YMMV. I changed your > newline matches to use \s and put some capturing parentheses around > the date, so you could grab it. I've been meaning to learn how to use parenthesis groups. > Also, be sure to > use a raw string when composing REs, so you don't run into backslash > issues. How would I do that when grabbing strings from a config file (via the configparser module)? Or rather, if I have a predefined variable containing a string, how do change it into a raw string?