"gburde...@gmail.com" wrote:
> If I do this:
>
> import re
> a=re.search(r'hello.*?money', 'hello how are you hello funny money')
>
> I would expect a.group(0) to be "hello funny money", since .*? is a
> non-greedy match. But instead, I get the whole sentence, "hello how
> are you hello funny
On Sep 6, 11:23 pm, Ben Finney wrote:
> George Burdell writes:
> > I want to find every occurrence of "money," and for each
> > occurrence, I want to scan back to the first occurrence
> > of "hello." How can this be done?
>
> By recognising the task: not expression matching, but lexing and
> pars
George Burdell wrote:
On Sep 6, 10:06 pm, "Mark Tolonen" wrote:
wrote in message
news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com...
If I do this:
import re
a=re.search(r'hello.*?money', 'hello how are you hello funny money')
I would expect a.group(0) to be "hello fun
On Sep 6, 8:46 pm, "gburde...@gmail.com" wrote:
> If I do this:
>
> import re
> a=re.search(r'hello.*?money', 'hello how are you hello funny money')
>
> I would expect a.group(0) to be "hello funny money", since .*? is a
> non-greedy match. But instead, I get the whole sentence, "hello how
> are
George Burdell writes:
> I want to find every occurrence of "money," and for each occurrence, I
> want to scan back to the first occurrence of "hello." How can this be
> done?
By recognising the task: not expression matching, but lexing and
parsing. For which you might find the ‘pyparsing’ libra
George Burdell wrote:
On Sep 6, 10:06 pm, "Mark Tolonen" wrote:
wrote in message
news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com...
If I do this:
import re
a=re.search(r'hello.*?money', 'hello how are you hello funny money')
I would expect a.gr
On Sep 6, 10:06 pm, "Mark Tolonen" wrote:
> wrote in message
>
> news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com...
>
> > If I do this:
>
> > import re
> > a=re.search(r'hello.*?money', 'hello how are you hello funny money')
>
> > I would expect a.group(0) to be "hello fun
On Sep 6, 10:22 pm, George Burdell wrote:
> On Sep 6, 10:06 pm, "Mark Tolonen" wrote:
>
>
>
>
>
> > wrote in message
>
> >news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com...
>
> > > If I do this:
>
> > > import re
> > > a=re.search(r'hello.*?money', 'hello how are you hell
On Sep 6, 10:06 pm, "Mark Tolonen" wrote:
> wrote in message
>
> news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com...
>
> > If I do this:
>
> > import re
> > a=re.search(r'hello.*?money', 'hello how are you hello funny money')
>
> > I would expect a.group(0) to be "hello fun
EDIT:
your regex matches the whole string because it means...
"hello" followed by any number of *anythings* up to the first
occurrence of "money")
you see?
--
http://mail.python.org/mailman/listinfo/python-list
wrote in message
news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com...
If I do this:
import re
a=re.search(r'hello.*?money', 'hello how are you hello funny money')
I would expect a.group(0) to be "hello funny money", since .*? is a
non-greedy match. But instead, I get th
On Sep 6, 9:46 pm, "gburde...@gmail.com" wrote:
> If I do this:
>
> import re
> a=re.search(r'hello.*?money', 'hello how are you hello funny money')
>
> I would expect a.group(0) to be "hello funny money", since .*? is a
> non-greedy match. But instead, I get the whole sentence, "hello how
> are
If I do this:
import re
a=re.search(r'hello.*?money', 'hello how are you hello funny money')
I would expect a.group(0) to be "hello funny money", since .*? is a
non-greedy match. But instead, I get the whole sentence, "hello how
are you hello funny money".
Is this expected behavior? How can I s
13 matches
Mail list logo