Regular Expression Groups - loop

2007-08-07 Thread shahargs
Hi,
I'm trying to write application which parse one page to sentences and
then, check every group for few things.

The code:
rawstr = r"""([^.?!]+[.?!])"""
regex=re.compile(rawstr)
matchs=regex.search(document)
document, is the text i parsing. I cheked it in Kodos, and everything
worked well. but, i'm trying to write for loop which check every
group.

I tried:
for group in matchs.groups():
but then, it's check only the first group. and i tried:
for group in matchs.group():
but then it's checking every letter, not every sentence.

is anyone know how i should write this loop to check every group on
the groups collection that the regular expression return?

Shahar.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regular Expression Groups - loop

2007-08-07 Thread shahargs
Thank You, Marc and Peter. now, it's working.

Shahar.

-- 
http://mail.python.org/mailman/listinfo/python-list


get wikipedia source failed (urrlib2)

2007-08-07 Thread shahargs
Hi,
I'm trying to get wikipedia page source with urllib2:
usock = urllib2.urlopen("http://en.wikipedia.org/wiki/
Albert_Einstein")
data = usock.read();
usock.close();
return data
I got exception because HTTP 403 error. why? with my browser i can't
access it without any problem?

Thanks,
Shahar.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get wikipedia source failed (urrlib2)

2007-08-07 Thread shahargs
On 7   , 11:54, [EMAIL PROTECTED] wrote:
> Hi,
> I'm trying to get wikipedia page source with urllib2:
> usock = urllib2.urlopen("http://en.wikipedia.org/wiki/
> Albert_Einstein")
> data = usock.read();
> usock.close();
> return data
> I got exception because HTTP 403 error. why? with my browser i can't
> access it without any problem?
>
> Thanks,
> Shahar.

This source works fine for other site. the problem is in wikipedia. is
someone now any solution for this problem?

-- 
http://mail.python.org/mailman/listinfo/python-list


check if regeular expression has results

2007-08-09 Thread shahargs
Hi,
I'm looking for the best way to check if regular expression return
true (it's mean - there is a match). for example, i want "if" that
check if this regular expression: .*born.*to.* has a match.

What's the way to do that simply?

Thanks a lot,
Shahar.

-- 
http://mail.python.org/mailman/listinfo/python-list