Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-25-2009, 05:45 AM   #1
hover
Junior Member
hover began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2009
Device: Amazon Kindle 2
Multiline Regex Footer

Hey,

since many hours im trying to cut the page number of an ebook with the "footer remove" option.
Code:
4&nbsp;<br>
&nbsp;<br>
<hr>
<A name=5></a>&nbsp;<br>
PROLOG &nbsp;<br>
&nbsp;<br>
This is the code i try to cut and i fail because there are multiple lines.

I have searched this board and many other regex, but didnt find a solution.
My tries so far:
Code:
(?m)((&nbsp;<br>)(<hr>))
Code:
^((\d+&nbsp;<br>)\n(&nbsp;<br>)\n(<hr>)\n(<A name=\d+</a>&nbsp;<br>))^
I tried them in every possible constelation, but i think that this calibre regex blocks multiline?

Thanks for answers!
hover is offline   Reply With Quote
Old 10-25-2009, 09:45 AM   #2
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,433
Karma: 950001
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by hover View Post
I tried them in every possible constelation, but i think that this calibre regex blocks multiline?
Multi line works fine but you need to check what kind of line ending is being used. It could be \r\n or just \n. A way to avoid that is to use (\r\n|\n) or (\r*\n).
user_none is offline   Reply With Quote
 
Enthusiast
Old 10-25-2009, 02:46 PM   #3
hover
Junior Member
hover began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2009
Device: Amazon Kindle 2
Thanks for the comment, but i dont get it.
I have tried every possibility i can:
Code:
(\d+&nbsp;<br>(\r\n)&nbsp;<br>(\r\n)<hr>)
(\d+&nbsp;<br>\r\n&nbsp;<br>\r\n<hr>)
(\d+&nbsp;<br>\n&nbsp;<br>\n<hr>)
(\d+&nbsp;<br>&nbsp;<br><hr>)\n
((\d+&nbsp;<br>)(\r\n)(&nbsp;<br>)(\r\n)(<hr>))
nothing works, thanks

Last edited by hover; 10-25-2009 at 02:48 PM.
hover is offline   Reply With Quote
Old 10-25-2009, 04:44 PM   #4
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,433
Karma: 950001
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Hm... try replacing &nbsp; with .+? and see if that makes a difference.
user_none is offline   Reply With Quote
Old 10-26-2009, 12:05 PM   #5
hover
Junior Member
hover began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2009
Device: Amazon Kindle 2
thanks but the regex findes the &nbsp; line, if its only 1 line.
But if i go multiline, it doesnt find the 2nd and so on lines..

I have searched for hours and nobody knows how to go multiline with regex
hover is offline   Reply With Quote
Old 10-26-2009, 12:07 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,380
Karma: 4961459
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Add (?m) to the start of the regex

See http://docs.python.org/library/re.html
kovidgoyal is offline   Reply With Quote
Old 10-26-2009, 08:14 PM   #7
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,433
Karma: 950001
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
I've made some changes to where in the conversion process the regex matches to remove the content. Subsequent versions it will work better.
user_none is offline   Reply With Quote
Old 10-27-2009, 05:01 AM   #8
hover
Junior Member
hover began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2009
Device: Amazon Kindle 2
thanks for the (?m) hint but i still dont get it:
Code:
(?m,"&nbsp;<br>\n<hr>")
(?m)(&nbsp;<br>\n<hr>)
(?m)((&nbsp;<br>)\n(<hr>))
any other clues? thanks
hover is offline   Reply With Quote
Old 02-02-2010, 11:39 AM   #9
tschan
Junior Member
tschan began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2009
Device: Sony PRS-505
I've got the same task at hand. Matching a multiline footer. Adding "(?m)" to the beginning of the expression doesn't work either. Any ideas?
tschan is offline   Reply With Quote
Old 02-03-2010, 03:50 AM   #10
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80446
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
I've had quite similar problems.
Manichean is offline   Reply With Quote
Old 02-03-2010, 04:23 AM   #11
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 4,989
Karma: 802238
Join Date: Jan 2010
Location: France
Device: Many android devices
Given the input
Code:
4&nbsp;<br>
&nbsp;<br>
<hr>
<A name=5></a>&nbsp;<br>
PROLOG &nbsp;<br>
&nbsp;<br>
Try "(?m)^\d+&nbsp;<br>\s+&nbsp;<br>$". This should match the first two lines. Add grouping parentheses if you need them.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure Detection - Remove Header (or Footer) Regex DarkKipper Conversion 69 11-09-2013 12:21 PM
Regex help to remove HTML footer neonbible Calibre 4 09-09-2010 09:42 AM
footer removal help icy Calibre 7 08-27-2010 01:21 PM
HTML Conversion - Multiline Headers prky Calibre 1 07-03-2010 09:24 AM
Multiline Regex? prky Calibre 25 05-01-2010 09:56 PM


All times are GMT -4. The time now is 04:13 PM.


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