Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56036
| Path | csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'produces': 0.07; 'match.': 0.09; 'subject:()': 0.09; 'pm,': 0.12; 'wrote:': 0.14; 'subject:returning': 0.16; 'feb': 0.16; 'figure': 0.16; 'cc:no real name:2**0': 0.17; 'cheers,': 0.17; 'skip:r 30': 0.18; 'cc:2**0': 0.21; 'trying': 0.22; 'emphasis': 0.23; 'header:In- Reply-To:1': 0.23; 'cc:addr:python-list': 0.24; 'matching': 0.24; 'string': 0.27; 'url:blog': 0.27; 'url:library': 0.28; "i'm": 0.28; 'message-id:@mail.gmail.com': 0.29; 'pattern': 0.30; 'stops': 0.30; 'match': 0.30; 'cc:addr:python.org': 0.30; 'import': 0.31; 'expression': 0.31; 'thu,': 0.31; "doesn't": 0.32; 'instances': 0.34; 'where': 0.35; 'url:docs': 0.35; 'regular': 0.37; 'think': 0.37; 'docs': 0.37; 'location': 0.37; 'received:209.85': 0.38; 'received:google.com': 0.38; 'url:org': 0.38; 'subject:: ': 0.39; 'url:python': 0.39; '12:32': 0.84; 'stupid': 0.84; 'url:re': 0.84; 'hence,': 0.91; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type; bh=k29vyBIdSw5ss1rdpwsOxLdnhu1o0YcqJh/NxX+h1kg=; b=Mit22iy0NwHlJ6SY8LUbal64Go6XO54TMt+7lObOe1xAyZTAwaw80/ynf6cecndmkR 16GcP7sprtzUW23tCyEKIqrXIITrIahB1CjD1c2JHi21AMVSJoHh8kUnd2a7H3HpKOd0 dmqiFKoufnAY2BcmTo1siGY0OySudOBNqW+Bk= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type; b=Edz8WabFqYspN8Xmylala4dLSQicyJ/FD/InigvdMDptaNb0iB2VGOrtKt7UKYpU25 nc4iUQ+rBwiH5+F7JKZlNSqdaK04V+wRTh00b01GgDr/zzMoKQkmFrsr594E1SbvjEo/ UnUbh/cRKrlxK0oVSHbHb0zkZjD26yiisRuRI= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <ed19857d-3b5e-4c46-87b3-9dedb0ad20ed@a28g2000vbo.googlegroups.com> |
| References | <ed19857d-3b5e-4c46-87b3-9dedb0ad20ed@a28g2000vbo.googlegroups.com> |
| Date | Thu, 3 Feb 2011 12:42:55 -0800 |
| X-Google-Sender-Auth | PNIwxxvPasuvN0We3xX73EXF9nI |
| Subject | Re: returning all matching groups with re.search() |
| From | Chris Rebert <clp2@rebertia.com> |
| Cc | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| 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.1630.1296765779.6505.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1296765779 news.xs4all.nl 41102 [::ffff:82.94.164.166]:50637 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:56036 |
Show key headers only | View raw
On Thu, Feb 3, 2011 at 12:32 PM,
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com
<mhearne808@gmail.com> wrote:
> Here's a scenario:
>
> import re
> m = re.search('e','fredbarneybettywilma')
>
> Now, here's a stupid question:
> why doesn't m.groups() return ('e','e','e').
Straight from the docs (http://docs.python.org/library/re.html ), emphasis mine:
re.search(pattern, string[, flags])
"Scan through string looking for **a** location where the regular
expression pattern produces **a** match [...]"
Hence, it stops looking after the very first match.
> I'm trying to figure out how to match ALL of the instances of a
> pattern in one call - the group() and groups() return subgroups... how
> do I get my search to get me all of the matching subgroups?
I think you want re.finditer() or re.findall().
Cheers,
Chris
--
http://blog.rebertia.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
returning all matching groups with re.search() "mhearne808[insert-at-sign-here]gmail[insert-dot-here]com" <mhearne808@gmail.com> - 2011-02-03 12:32 -0800 Re: returning all matching groups with re.search() Chris Rebert <clp2@rebertia.com> - 2011-02-03 12:42 -0800
csiph-web