Re: regular expression - matches

2006-07-24 Thread John Machin
On 22/07/2006 2:18 AM, Simon Forman wrote: > John Salerno wrote: >> Simon Forman wrote: >> >>> Python's re.match() matches from the start of the string, so if you (1) Every regex library's match() starts matching from the beginning of the string (unless of course there's an arg for an explicit s

Re: regular expression - matches

2006-07-21 Thread John Machin
On 22/07/2006 9:25 AM, John Machin wrote: Apologies if this appears twice ... post to the newsgroup hasn't shown up; trying the mailing-list. > On 22/07/2006 2:18 AM, Simon Forman wrote: >> John Salerno wrote: >>> Simon Forman wrote: >>> Python's re.match() matches from the start of the str

Re: regular expression - matches

2006-07-21 Thread Simon Forman
John Salerno wrote: > Thanks guys! A pleasure. : ) -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression - matches

2006-07-21 Thread John Salerno
Simon Forman wrote: > John Salerno wrote: >> Simon Forman wrote: >> >>> Python's re.match() matches from the start of the string, so if you >>> want to ensure that the whole string matches completely you'll probably >>> want to end your re pattern with the "$" character (depending on what >>> the r

Re: regular expression - matches

2006-07-21 Thread Simon Forman
John Salerno wrote: > Simon Forman wrote: > > > Python's re.match() matches from the start of the string, so if you > > want to ensure that the whole string matches completely you'll probably > > want to end your re pattern with the "$" character (depending on what > > the rest of your pattern matc

Re: regular expression - matches

2006-07-21 Thread Steve Holden
John Salerno wrote: > Simon Forman wrote: > > >>Python's re.match() matches from the start of the string, so if you >>want to ensure that the whole string matches completely you'll probably >>want to end your re pattern with the "$" character (depending on what >>the rest of your pattern matches.

Re: regular expression - matches

2006-07-21 Thread John Salerno
Simon Forman wrote: > Python's re.match() matches from the start of the string, so if you > want to ensure that the whole string matches completely you'll probably > want to end your re pattern with the "$" character (depending on what > the rest of your pattern matches.) Is that necessary? I was

Re: regular expression - matches

2006-07-21 Thread James Oakley
On Friday 21 July 2006 10:57 am, abcd wrote: > yea i saw thatguess I was trusting that my regex was accurate :) > ...b/c i was getting a Matcher when I shouldnt have, but i found that > it must be the regex. http://kodos.sourceforge.net/ Makes regex generation and debugging much easier. --

Re: regular expression - matches

2006-07-21 Thread Simon Forman
abcd wrote: > how can i determine if a given character sequence matches my regex, > completely? > > in java for example I can do, > Pattern.compile(regex).matcher(input).matches() > > this returns True/False whether or not input matches the regex > completely. > > is there a matches in python? Yes

Re: regular expression - matches

2006-07-21 Thread abcd
yea i saw thatguess I was trusting that my regex was accurate :) ...b/c i was getting a Matcher when I shouldnt have, but i found that it must be the regex. -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression - matches

2006-07-21 Thread Tim Chase
abcd wrote: > how can i determine if a given character sequence matches my regex, > completely? > > in java for example I can do, > Pattern.compile(regex).matcher(input).matches() > > this returns True/False whether or not input matches the regex > completely. > > is there a matches in python?

regular expression - matches

2006-07-21 Thread abcd
how can i determine if a given character sequence matches my regex, completely? in java for example I can do, Pattern.compile(regex).matcher(input).matches() this returns True/False whether or not input matches the regex completely. is there a matches in python? -- http://mail.python.org/mailm

Re: Overlapping Regular Expression Matches With findall()

2005-12-15 Thread Fredrik Lundh
Mystilleef wrote: > Thanks for your response. I was going by the definition in > the manual. "non-overlapping" in that context means that if you e.g. search for "(ba)+" in the string "bababa", you get one match ("bababa"), not three or six. in your case, it sounds like you want a search for "ba"

Re: Overlapping Regular Expression Matches With findall()

2005-12-15 Thread Bengt Richter
On Thu, 15 Dec 2005 20:33:42 +, Simon Brunning <[EMAIL PROTECTED]> wrote: >On 15 Dec 2005 12:26:07 -0800, Mystilleef <[EMAIL PROTECTED]> wrote: >> I want a pattern that scans the entire string but avoids >> returning duplicate matches. For example "cat", "cate", >> "cater" may all well be vali

Re: Overlapping Regular Expression Matches With findall()

2005-12-15 Thread Simon Brunning
On 15 Dec 2005 12:26:07 -0800, Mystilleef <[EMAIL PROTECTED]> wrote: > I want a pattern that scans the entire string but avoids > returning duplicate matches. For example "cat", "cate", > "cater" may all well be valid matches, but I don't want > duplicate matches of any of them. I know I can filter

Re: Overlapping Regular Expression Matches With findall()

2005-12-15 Thread Mystilleef
Hello, Thanks for your response. I was going by the definition in the manual. I believe a search only returns the first match of a regular expression pattern in a string and then stops further searches if one is found. That's not what I want. I want a pattern that scans the entire string but avoi

Re: Overlapping Regular Expression Matches With findall()

2005-12-15 Thread Fredrik Lundh
"Mystilleef" wrote: > Is there a simple flag to set to allow overlapping matches > for the findall() regular expression method? In other words, > if a string contains five occurrences of the string pattern > "cat", calling findall on the string returns a list > containing five "cat" strings. Is it

Overlapping Regular Expression Matches With findall()

2005-12-15 Thread Mystilleef
Hello, Is there a simple flag to set to allow overlapping matches for the findall() regular expression method? In other words, if a string contains five occurrences of the string pattern "cat", calling findall on the string returns a list containing five "cat" strings. Is it possible for findall()