simple regular expression problem

2007-09-17 Thread duikboot
Hello,

I am trying to extract a list of strings from a text. I am looking it
for hours now, googling didn't help either.
Could you please help me?

>>>s = """ 
>>>\n\n28996\n\n\n28997\n"""
>>> regex = re.compile(r'', re.S)
>>> L = regex.findall(s)
>>> print L
['organisatie>\n28996\n
\n\n28997\n\n28996\n
\n), (\n28997\nhttp://mail.python.org/mailman/listinfo/python-list


Re: simple regular expression problem

2007-09-17 Thread duikboot
Thank you very much, it works. I guess I didn't read it right.

Arjen

On Sep 17, 3:22 pm, Jason Drew <[EMAIL PROTECTED]> wrote:
> You just need a one-character addition to your regex:
>
> regex = re.compile(r'', re.S)
>
> Note, there is now a question mark (?) after the .*
>
> By default, regular expressions are "greedy" and will grab as much
> text as possible when making a match. So your original expression was
> grabbing everything between the first opening tag and the last closing
> tag. The question mark says, don't be greedy, and you get the
> behaviour you need.
>
> This is covered in the documentation for the re 
> module.http://docs.python.org/lib/module-re.html
>
> Jason
>
> On Sep 17, 9:00 am, duikboot <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I am trying to extract a list of strings from a text. I am looking it
> > for hours now, googling didn't help either.
> > Could you please help me?
>
> > >>>s = """ 
> > >>>\n\n28996\n\n\n28997\n"""
> > >>> regex = re.compile(r'', re.S)
> > >>> L = regex.findall(s)
> > >>> print L
>
> > ['organisatie>\n28996\n
> > \n\n28997\n
> > I expected:
> > [('organisatie>\n28996\n
> > \n), (\n28997\n > organisatie')]
>
> > I must be missing something very obvious.
>
> > Greetings Arjen

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


Re: Python train spotting doodle

2006-03-17 Thread Duikboot
http://apipes.blogspot.com/2005/01/choose-python.html

I have printed on my office wall too.

Duikboot

Diez B. Roggisch wrote:
> Hi,
> 
> a year or two ago, somebody posted a link to an image he created. It was
> basically a remake of the famous trainspotting-poster that begins all
> sentences with "Choose ..."
> 
> Back then I printed it out and hung it on my office wall. New emplyoer,
> empty wall, crying for a printout...
> 
> But I didn't find it - any pointers are greatly appreciated.
> 
> regards,
> 
> Diez
-- 
http://mail.python.org/mailman/listinfo/python-list