On Mar 22, 3:26 am, "Johny" <[EMAIL PROTECTED]> wrote:
> I have  the following text
>
> <title>Goods Item  146 (174459989)  - OurWebSite</title>
>
> from which I need to extract
> `Goods Item  146 '
>
> Can anyone help with regexp?
> Thank you for help
> L.
Here's the immediate answer to your question.


import re
src = "<title>Goods Item  146 (174459989)  - OurWebSite</title>"
pattern = r"<title>(.*)\("
re.search(pattern,src).groups()[0]


I post it this way so that you can relate the re to your specific
question, and then maybe apply this to whatever else you are scraping
from this web page.

Please don't follow up with a post asking how to extract "45","Rubber
chicken" from "<tr><td>45</td><td>Rubber chicken</td></tr>".  At this
point, you should try a little experimentation on your own.

-- Paul

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

Reply via email to