![]() |
#1 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
|
"preprocess_regexps with special character '
I need to get rid of the 2 characters \' and replace with just '
trouble is using preprocess_regexps fails due to the ' I did a search but came up short - i think from one thread maybe hex code of the character has to be used... can someone give the correct syntax? |
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,856
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
\\\' |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
|
I tried that in the following
preprocess_regexps = [ (re.compile(r'\\\'', re.IGNORECASE | re.DOTALL), lambda match: '`')] I used ` as the replacement because ''' fails. It didn't work. Here is an example of text i'm trying to clean up. 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! |
![]() |
![]() |
![]() |
#4 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,856
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
My regex search \\\' found all and a simple ' was the replace Go Sigil IMHO fix it outside, it is so easy that way ![]() |
|
![]() |
![]() |
![]() |
#5 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
|
Quote:
I just noticed everything after '\\\'' is light brown - which means it's being treated as part of the string (I guess due to double '') |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,856
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
@sissors, should I put on my Mod hat and move this thread to Recipies?
|
![]() |
![]() |
![]() |
#7 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
|
I was gonna put it in recipes, but then i thought it was more a general syntax query.
Feel free to move it. |
![]() |
![]() |
![]() |
#8 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,856
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Moderator Notice
Moved |
![]() |
![]() |
![]() |
#9 |
doofus
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,543
Karma: 13088847
Join Date: Sep 2010
Device: Kobo Libra 2, Kindle Voyage
|
Don't quote me on this (haha), but try
Code:
preprocess_regexps = [ (re.compile(r"\\'", re.IGNORECASE | re.DOTALL), lambda match: "'")] |
![]() |
![]() |
![]() |
#10 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
|
Quote:
You'd think that would work... here's a piece of the web page source - i can't see why that wouldn't work "caption": "<p>This American actress is setting tinseltown alight with her pretty looks and impressive acting ability. She rose to fame for her role in \'True Grit\' and was even nominated for an Academy Award and a BAFTA. The teen star is creating quite a splash in the fashion arena too, just recently her Miu Miu advert got banned for being \'irresponsible\'. Eek! We predict front row action at February\'s international fashion weeks</p>" |
|
![]() |
![]() |
![]() |
#11 | |
Reader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
|
|
![]() |
![]() |
![]() |
#12 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 241
Karma: 1001369
Join Date: Sep 2010
Device: prs300, kindle keyboard 3g
|
Quote:
In the meantime it looks like it was only that one article that was done in that way.... |
|
![]() |
![]() |
![]() |
#13 |
Reader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 520
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
|
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
"preprocess_regexps = [(re.compile..." bugged? | scissors | Recipes | 8 | 11-02-2011 03:56 PM |
special character in metadata search | happyuser | Calibre | 1 | 10-19-2011 11:33 AM |
Special Character searches | ElMiko | Calibre | 2 | 09-05-2011 10:52 PM |
-iBookstore- "His Niji" Realistic Character based Story-Telling | Rollzlx | Self-Promotions by Authors and Publishers | 11 | 10-31-2010 03:23 PM |
"ascii' codec can't encode character" bug ? | zelda_pinwheel | Calibre | 2 | 12-21-2008 08:12 PM |