Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32180
| Date | 2012-10-26 03:11 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2874.1351217512.27098.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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