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


Groups > comp.lang.python > #32168

Re: Quickie - Regexp for a string not at the beginning of the line

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <z@etiol.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.057
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'subject:string': 0.09; 'subject:not': 0.11; '"this': 0.13; 'string': 0.17; 'wrote:': 0.17; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'probably': 0.29; 'received:209.85.210.174': 0.30; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'october': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'miller': 0.69
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:x-originating-ip:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:content-type :x-gm-message-state; bh=ceTD95oTGUnsOj41GiyDIPPjeF9DbWJv+r45+S9UR1o=; b=iWpOfq0F4vYkbOi/bh+uZ9ejMWGeMDUkdb1+xGfUHXNfSNaKj3f9wCxE/jMjtevcEb zBBkChOWNrtH9aAsac+n2MUz31RsMuwqiIg5xf/uxHUSIJeBsg83BMind1RrB5tPTaf+ 9dnX1HEoFIQaLVOI7wWY+oYk4RhYoOpYnqFpYeMGky3dTaKsIx/0l7tH5C11ibyIAhc3 9AJsQHg6k6AUl3n+3V3tbCw0cQatGWS7bEslnx7WTxlZeaLyOIAmq1TO54kTO34oi1km YWXPgtgwHGISEpZidmwKIkVlqrVz9vn1YazYv3XlJwH97mPlg8EHfFPXRTSRUAK9kDS0 Bz2A==
MIME-Version 1.0
Sender z@etiol.net
X-Originating-IP [190.104.27.29]
In-Reply-To <9eba5652-f814-41fa-83e4-460bca2be264@n16g2000yqi.googlegroups.com>
References <9eba5652-f814-41fa-83e4-460bca2be264@n16g2000yqi.googlegroups.com>
From Zero Piraeus <schesis@gmail.com>
Date Thu, 25 Oct 2012 17:21:32 -0400
X-Google-Sender-Auth 40wBa1pacMIrbNXcuQ0ZYQK2iaQ
Subject Re: Quickie - Regexp for a string not at the beginning of the line
To python-list@python.org
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQmLDyUZWM4edB8GGDBAZhfZ5uUOLc2wwtoKisCaGzhlJ/eFMmDj7QdB62XZmp3AKlIOhXsp
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.2868.1351200115.27098.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351200115 news.xs4all.nl 6863 [2001:888:2000:d::a6]:55732
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32168

Show key headers only | View raw


:

On 25 October 2012 16:53, Rivka Miller <rivkaumiller@gmail.com> wrote:
> I am looking for a regexp for a string not at the beginning of the
> line.

There are probably quite a few ways to do this, but '(?<!^)PATTERN'
has the advantage of explicitly describing what you're trying to do.
For instance:

>>> pattern = re.compile(r"(?<!^)\b\w+\b")
>>> re.findall(pattern, "this is some text")
['is', 'some', 'text']

 -[]z.

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


Thread

Quickie - Regexp for a string not at the beginning of the line Rivka Miller <rivkaumiller@gmail.com> - 2012-10-25 13:53 -0700
  Re: Quickie - Regexp for a string not at the beginning of the line Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-10-25 23:01 +0200
  Re: Quickie - Regexp for a string not at the beginning of the line Zero Piraeus <schesis@gmail.com> - 2012-10-25 17:21 -0400
  Re: Quickie - Regexp for a string not at the beginning of the line Rivka Miller <rivkaumiller@gmail.com> - 2012-10-25 18:08 -0700
    Re: Quickie - Regexp for a string not at the beginning of the line Dave Angel <d@davea.name> - 2012-10-25 21:21 -0400
    Re: Quickie - Regexp for a string not at the beginning of the line Ed Morton <mortonspam@gmail.com> - 2012-10-25 21:00 -0500
      Re: Quickie - Regexp for a string not at the beginning of the line Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-10-26 01:08 -0400
    Re: Quickie - Regexp for a string not at the beginning of the line Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-26 03:11 +0100
      Re: Quickie - Regexp for a string not at the beginning of the line Rivka Miller <rivkaumiller@gmail.com> - 2012-10-25 21:45 -0700
        Re: Quickie - Regexp for a string not at the beginning of the line Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-10-26 11:18 +0200
        Re: Quickie - Regexp for a string not at the beginning of the line Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-10-26 13:11 +0100
        Re: Quickie - Regexp for a string not at the beginning of the line Ed Morton <mortonspam@gmail.com> - 2012-10-26 07:32 -0500
          Re: Quickie - Regexp for a string not at the beginning of the line Joel Goldstick <joel.goldstick@gmail.com> - 2012-10-26 08:53 -0400
    Re: Quickie - Regexp for a string not at the beginning of the line MRAB <python@mrabarnett.plus.com> - 2012-10-26 03:11 +0100
    Re: Quickie - Regexp for a string not at the beginning of the line David Hutto <dwightdhutto@gmail.com> - 2012-10-25 23:02 -0400
    Re: Quickie - Regexp for a string not at the beginning of the line anon@anon.anon - 2012-10-25 23:22 -0400
  Re: Quickie - Regexp for a string not at the beginning of the line Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-26 03:37 +0100
  Re: Quickie - Regexp for a string not at the beginning of the line Asen Bozhilov <asen.bozhilov@gmail.com> - 2012-10-26 03:46 -0700

csiph-web