View Single Post
Old 12-27-2011, 11:02 AM   #11
pietvo
Reader
pietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notes
 
pietvo's Avatar
 
Posts: 520
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
Please note that that source code is part of Javascript on the website. So the question is what are you doing with the result of the substitution?

The substitution itself should work:
Quote:
>>> import re
>>> regex = re.compile(r"\\'", re.IGNORECASE | re.DOTALL)
>>> text = r"""Lana is one of 2011\'s biggest success stories. The gorgeous songstress found fame on the internet with her songs \'Video Games\' and \'Blue Jeans\'. Since then she has been everywhere, even singing for the fash pack at the Mulberry pool party in LA. With the soon to be released \'Born To Die\' we will all wonder how we ever coped without her slick vocals. Watch out 2012, Lana is coming!"""
>>> print text
Lana is one of 2011\'s biggest success stories. The gorgeous songstress found fame on the internet with her songs \'Video Games\' and \'Blue Jeans\'. Since then she has been everywhere, even singing for the fash pack at the Mulberry pool party in LA. With the soon to be released \'Born To Die\' we will all wonder how we ever coped without her slick vocals. Watch out 2012, Lana is coming!
>>> print regex.sub(lambda match: "'", text)
Lana is one of 2011's biggest success stories. The gorgeous songstress found fame on the internet with her songs 'Video Games' and 'Blue Jeans'. Since then she has been everywhere, even singing for the fash pack at the Mulberry pool party in LA. With the soon to be released 'Born To Die' we will all wonder how we ever coped without her slick vocals. Watch out 2012, Lana is coming!
pietvo is offline   Reply With Quote