Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'expressions.': 0.09; 'matt': 0.09; 'subject:python': 0.11; "doesn't.": 0.16; 'offense': 0.16; 'shed': 0.16; 'subject:expression': 0.16; 'subject:regular': 0.16; 'wrote:': 0.16; 'subject:Help': 0.17; 'to:2**1': 0.20; 'figure': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; '(just': 0.23; "skip:' 40": 0.23; 'pm,': 0.24; '(in': 0.26; 'work.': 0.27; 'scientific': 0.28; 'martin': 0.28; 'problem': 0.28; 'matches': 0.29; 'example': 0.30; 'match': 0.30; 'times.': 0.30; 'line:': 0.30; 'whitespace': 0.30; 'thanks': 0.30; 'seem': 0.31; 'expression': 0.32; 'go.': 0.32; 'hi,': 0.32; 'does': 0.32; 'it.': 0.33; "can't": 0.33; 'there': 0.33; 'to:addr:python-list': 0.33; 'light': 0.34; 'however,': 0.34; 'someone': 0.34; 'header :User-Agent:1': 0.34; 'quite': 0.34; 'list.': 0.35; 'to:no real name:2**1': 0.35; 'supposed': 0.35; 'regular': 0.35; 'question': 0.36; 'using': 0.37; 'some': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'subject:with': 0.39; 'format.': 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; 'description': 0.39; "i'd": 0.40; 'where': 0.40; 'subject': 0.61; 'received:cz': 0.63; 'vary': 0.64; 'account': 0.66; 'floats.': 0.84; 'funk': 0.84 X-Spam-Score: -99.189 X-Spam-Level: X-Spam-Status: No, score=-99.189 tagged_above=-255 required=5 tests=[AWL=0.386, CRM114_HAM_00=, NO_RELAYS=-0.001, RATWARE_GECKO_BUILD=1.426, SMTPAUTH_SHDOMAIN=-100] Date: Thu, 18 Aug 2011 21:59:32 +0200 From: =?UTF-8?B?TWFydGluIEtvbW/FiA==?= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: matze999@gmail.com, python-list@python.org Subject: Re: Help with regular expression in python References: <201108181349.54727.matze999@gmail.com> In-Reply-To: <201108181349.54727.matze999@gmail.com> X-Enigmail-Version: 1.3 Content-Type: text/plain; charset=UTF-8 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313697584 news.xs4all.nl 23849 [2001:888:2000:d::a6]:35748 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11803 You don't seem to account for the whitespace between the floats. Try > '([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?\s+){32}' (just added \s+). Martin On 8/18/2011 9:49 PM, Matt Funk wrote: > Hi, > i am sorry if this doesn't quite match the subject of the list. If someone > takes offense please point me to where this question should go. Anyway, i have > a problem using regular expressions. I would like to match the line: > > 1.002000e+01 2.037000e+01 2.128000e+01 1.908000e+01 1.871000e+01 1.914000e+01 > 2.007000e+01 1.664000e+01 2.204000e+01 2.109000e+01 2.209000e+01 2.376000e+01 > 2.158000e+01 2.177000e+01 2.152000e+01 2.267000e+01 1.084000e+01 1.671000e+01 > 1.888000e+01 1.854000e+01 2.064000e+01 2.000000e+01 2.200000e+01 2.139000e+01 > 2.137000e+01 2.178000e+01 2.179000e+01 2.123000e+01 2.201000e+01 2.150000e+01 > 2.150000e+01 2.199000e+01 : (instance: 0) : some description > > The number of floats can vary (in this example there are 32). So what i thought > i'd do is the following: > instance_linetype_pattern_str = '([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?) > {32}' > instance_linetype_pattern = re.compile(instance_linetype_pattern_str) > Basically the expression in the first major set of paranthesis matches a > scientific number format. The '{32}' is supposed to match the previous 32 > times. However, it doesn't. I can't figure out why this does not work. I'd > really like to understand it if someone can shed light on it. > > thanks > matt