Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 05-30-2018, 07:35 AM   #1
bobbysteel
Big Poppa
bobbysteel began at the beginning.
 
Posts: 110
Karma: 10
Join Date: Jul 2010
Device: Nook
How to do back-matches with preprocess_regexp

Hi Kovid et al
I'm trying to use preprocess_regexps more powerfully to do some rewriting and can't seem to make the back-matching work properly.
Code:
(re.compile(r'<li class="css.*?>(.*?)</li>', re.IGNORECASE), lambda match: '')
Sorry for the stupid question, but how could I perform the substitution such that the match would replace with the group(0) of that regexp match? match: group(0) fails.
bobbysteel is offline   Reply With Quote
Old 05-30-2018, 07:51 AM   #2
bobbysteel
Big Poppa
bobbysteel began at the beginning.
 
Posts: 110
Karma: 10
Join Date: Jul 2010
Device: Nook
Nevermind. For future reference for others this works:
Code:
..., lambda m: m.group(1)
works just fine
bobbysteel is offline   Reply With Quote
Reply


Forum Jump


All times are GMT -4. The time now is 09:18 PM.


MobileRead.com is a privately owned, operated and funded community.