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


Groups > comp.lang.python > #32180

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 <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'perl,': 0.07; 'literal': 0.09; 'occurrences': 0.09; 'subject:string': 0.09; 'subject:not': 0.11; 'suggest': 0.11; 'yet.': 0.13; 'language': 0.14; '(other': 0.16; 'danny': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'oct': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'regex,': 0.16; 'two,': 0.16; 'wrote:': 0.17; 'differ': 0.17; 'examples': 0.18; 'versions': 0.20; 'this:': 0.23; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'common': 0.26; 'set.': 0.27; 'multiline': 0.29; 'received:192.168.1.3': 0.29; 'maybe': 0.29; 'received:84': 0.32; 'could': 0.32; 'to:addr :python-list': 0.33; 'languages': 0.33; 'pm,': 0.35; 'posting': 0.35; 'there': 0.35; 'really': 0.36; 'except': 0.36; 'but': 0.36; 'should': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'possible.': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'most': 0.61; 'first': 0.61; 'different': 0.63; 'within': 0.64; 'dont': 0.64; 'header:Reply- To:1': 0.68; 'miller': 0.69; 'reply-to:no real name:2**0': 0.72; 'modify.': 0.84; 'reply-to:addr:python.org': 0.84; 'tied': 0.93
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=YaM/Fntf c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=b2nRVtXOy8EA:10 a=IRuoXFj7-j0A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=OMDHiQJKowQA:10 a=pGLkceISAAAA:8 a=YA_tXJZuWTgl8oHiuWQA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Fri, 26 Oct 2012 03:11:48 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Quickie - Regexp for a string not at the beginning of the line
References <9eba5652-f814-41fa-83e4-460bca2be264@n16g2000yqi.googlegroups.com> <e6f60702-d85f-4aed-bc03-3147bb007ad8@googlegroups.com> <73f60cf3-d932-4366-a405-6767488560c6@q16g2000yqc.googlegroups.com>
In-Reply-To <73f60cf3-d932-4366-a405-6767488560c6@q16g2000yqc.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
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.2874.1351217512.27098.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351217512 news.xs4all.nl 6843 [2001:888:2000:d::a6]:59363
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32180

Show key headers only | View raw


On 2012-10-26 02:08, Rivka Miller wrote:
> On Oct 25, 2:27 pm, Danny <dann90...@gmail.com> wrote:
>> Why you just don't give us the string/input, say a line or two, and what you want off of it, so we can tell better what to suggest
>
> no one has really helped yet.
>
> I want to search and modify.
>
> I dont wanna be tied to a specific language etc so I just want a
> regexp and as many versions as possible. Maybe I should try in emacs
> and so I am now posting to emacs groups also, although javascript has
> rich set of regexp facilities.
>
> examples
>
> $hello$ should not be selected but
> not hello but all of the $hello$ and $hello$ ... $hello$ each one
> selected
>
[snip]
To match the literal "$hello$" except at the start of a line, use:

(?<!^)\$hello\$

with the multiline flag set. You could set the multiline flag within
the regex like this:

(?m)(?<!^)\$hello\$

re.search will find the first occurrence. In order to find all such
occurrences in Python, you need to use re.findall or re.finditer.
(Other languages have their own ways.)

Note that there are different 'flavours' of regex, the most common form
following the lead of Perl, and that implementations might differ in
which features they support.

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