[TriZPUG] Regular expressions- my son getting me stuck!

Philip Semanchuk philip at semanchuk.com
Wed Jun 13 21:15:29 CEST 2012


On Jun 13, 2012, at 2:33 PM, Mark Browne wrote:

> do you know how to write regular expressions?
> this works
> (r'<span class="price">(.*?)</span>', html)
> 
> this doesn't
> (r'<div class="product-image-cropped"\.+\title="(.*?)">', html)

Hi Mark,
I use regexes just often enough to get in over my head. I've found the following utility invaluable:
http://cthedot.de/retest/

It runs locally and allows one to enter text and a regex to apply to that text, and shows the output in realtime. 

Hope this helps
Philip



> 
> I am trying to write the expression which means
> 
> find <div class="product-image-cropped
> 
> followed by a load of character which will change
> 
> and of undefined length
> 
> then grab title="this text whatever it is"
> 
> in html
> 
> Mark Browne
> R&D
> Andor Technology
> discover new ways of seeing
> 
> 
> [http://www.andor.com/newsletter/footer/sig.jpg]<http://www.andor.com/newsletter/footer>
> 
> 
> _______________________________________________
> TriZPUG mailing list
> TriZPUG at python.org
> http://mail.python.org/mailman/listinfo/trizpug
> http://trizpug.org is the Triangle Zope and Python Users Group



More information about the TriZPUG mailing list