On Apr 17, 5:30 pm, Paul McGuire wrote:
> On Apr 17, 5:28 pm, Paul McGuire wrote:> -- Paul
>
> > Your find pattern includes (and consumes) a leading AND trailing space
> > around each word. In the first string "I am an american", there is a
> > leading and trailing space around "am", but the tra
On Apr 17, 5:28 pm, Paul McGuire wrote:
> -- Paul
>
> Your find pattern includes (and consumes) a leading AND trailing space
> around each word. In the first string "I am an american", there is a
> leading and trailing space around "am", but the trailing space for
> "am" is the leading space for
On Apr 17, 4:49 pm, Jesse Aldridge wrote:
> import re
>
> s1 = "I am an american"
>
> s2 = "I am american an "
>
> for s in [s1, s2]:
> print re.findall(" (am|an) ", s)
>
> # Results:
> # ['am']
> # ['am', 'an']
>
> ---
>
> I want the results to be the same for each string. What am I doin
s1 = "I am an american"
s2 = "I am american an "
for s in [s1, s2]:
print re.findall(" (am|an) ", s)
# Results:
# ['am']
# ['am', 'an']
---
I want the results to be the same for each string. What am I doing
wrong?
In your first case, the regexp is consuming the " am " (four
charac
On 2009-04-17 16:49, Jesse Aldridge wrote:
import re
s1 = "I am an american"
s2 = "I am american an "
for s in [s1, s2]:
print re.findall(" (am|an) ", s)
# Results:
# ['am']
# ['am', 'an']
---
I want the results to be the same for each string. What am I doing
wrong?
findall() fi
On 2009-04-17 16:57, Eugene Perederey wrote:
According to documentation re.findall takes a compiled pattern as a
first argument. So try
patt = re.compile(r'(am|an)')
re.findall(patt, s1)
re.findall(patt, s2)
No, it will take a string pattern, too.
--
Robert Kern
"I have come to believe that t
According to documentation re.findall takes a compiled pattern as a
first argument. So try
patt = re.compile(r'(am|an)')
re.findall(patt, s1)
re.findall(patt, s2)
2009/4/18 Jesse Aldridge :
> import re
>
> s1 = "I am an american"
>
> s2 = "I am american an "
>
> for s in [s1, s2]:
> print re.fi