f*cking re module

Gurpreet Sachdeva gurpreet.sachdeva at gmail.com
Mon Jul 4 05:35:04 EDT 2005


try:
    re.search("(<python>)(/python>)", str).group()
except:
    print 'not found'

otherwise,

 re.search("(<python>).*?(\/python>)", str).group()

this is will help!

Regards,
Gurpreet Singh

Blogging [at] http://garrythegambler.blogspot.com

On 4 Jul 2005 01:04:47 -0700, jwaixs <jwaixs at gmail.com> wrote:
> arg... I've lost 1.5 hours of my precious time to try letting re work
> correcty. There's really not a single good re tutorial or documentation
> I could found! There are only reference, and if you don't know how a
> module work you won't learn it from a reference!
> 
> This is the problem:
> 
> >>> import re
> >>> str = "blabla<python>Re modules sucks!</python>blabla"
> >>> re.search("(<python>)(/python>)", str).group()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'NoneType' object has no attribute 'group'
> 
> the only thing I want are the number of places blabla, Re modules
> sucks! and blabla are.
> 
> Noud
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
Thanks and Regards,
GSS



More information about the Python-list mailing list