Re: Regular expression question -- exclude substring

2005-11-07 Thread Bengt Richter
On Mon, 7 Nov 2005 16:38:11 -0800, James Stroud <[EMAIL PROTECTED]> wrote: >On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote: >> Ya, for some reason your non-greedy "?" doesn't seem to be taking. >> This works: >> >> re.sub('(.*)(00.*?01) target_mark', r'\2', your_string) > >The non-greed

Re: Regular expression question -- exclude substring

2005-11-07 Thread James Stroud
On Monday 07 November 2005 17:31, Kent Johnson wrote: > James Stroud wrote: > > On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote: > >>Ya, for some reason your non-greedy "?" doesn't seem to be taking. > >>This works: > >> > >>re.sub('(.*)(00.*?01) target_mark', r'\2', your_string) > > > >

Re: Regular expression question -- exclude substring

2005-11-07 Thread Kent Johnson
James Stroud wrote: > On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote: > >>Ya, for some reason your non-greedy "?" doesn't seem to be taking. >>This works: >> >>re.sub('(.*)(00.*?01) target_mark', r'\2', your_string) > > > The non-greedy is actually acting as expected. This is because

Re: Regular expression question -- exclude substring

2005-11-07 Thread James Stroud
On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote: > Ya, for some reason your non-greedy "?" doesn't seem to be taking. > This works: > > re.sub('(.*)(00.*?01) target_mark', r'\2', your_string) The non-greedy is actually acting as expected. This is because non-greedy operators are "forwar

Re: Regular expression question -- exclude substring

2005-11-07 Thread google
Ya, for some reason your non-greedy "?" doesn't seem to be taking. This works: re.sub('(.*)(00.*?01) target_mark', r'\2', your_string) -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression question -- exclude substring

2005-11-07 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, > > I'm having trouble extracting substrings using regular expression. Here > is my problem: > > Want to find the substring that is immediately before a given > substring. For example: from > "00 noise1 01 noise2 00 target 01 target_mark", > want to get > "00 target

Regular expression question -- exclude substring

2005-11-07 Thread dreamerbin
Hi, I'm having trouble extracting substrings using regular expression. Here is my problem: Want to find the substring that is immediately before a given substring. For example: from "00 noise1 01 noise2 00 target 01 target_mark", want to get "00 target 01" which is before "target_mark". My regula