![]() |
#1 |
stumblebum
![]() Posts: 29
Karma: 10
Join Date: Nov 2013
Location: Roseburg, OR
Device: kindle2
|
![]() ![]() ![]() I have a book is really chopped up. Four lines in the editor for every book page for just headers. But I fixed those using S&R, no problem. The real problem is when I try to remove a bunch of the html tags to clean it up. You can see what I mean: Code:
<p class="calibre1">Fallon was shaking his head. “Let me tell you what the people in</p> <p class="calibre1">Washington say is stenciled on that woman’s undies. ‘Virginia Larue’s</p> <p class="calibre1">Home for Wayward Boys.’ Ginny Larue is a regular one-woman</p> I used this to find them. Code:
\w</p>\s<p.\w+..\w+.. Obviously, I can't use S&R to fix them without hosing my book. Is there any way that I rewrite the regular expression that won't select the last character just before the closing tag? Thank you. one of your faithful lurkers, ![]() larry |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,170
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
</p>\s+<p[^>]*>
This will remove all closing </p> tags followed by opening <p tags. You probably dont want to run this on the entire book, so use the marked region to do it. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
stumblebum
![]() Posts: 29
Karma: 10
Join Date: Nov 2013
Location: Roseburg, OR
Device: kindle2
|
Thank you Kovid. That works well. A lot more elegant than mine for sure.
Maybe I'm dreaming, but I was hoping to find something that would ignore the whole sentences with a (.) or a (") at the closing tag. That is why I started my searches with (\w</p>). It ignores the sentences with ending punctuation. But it picks up the ending character, which I could do without. There are 9655 reasons for my grasping at straws. I am at line 1282 by hand, so far. If I didn't like the book so well, I would have bagged it a long time ago. ![]() thanks, larry |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,170
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
(?<![".])</p>\s+<p[^>]*>
|
![]() |
![]() |
![]() |
#5 |
stumblebum
![]() Posts: 29
Karma: 10
Join Date: Nov 2013
Location: Roseburg, OR
Device: kindle2
|
Thank you, thank you, Kovid! You ARE "the man"! I saved it as "Kovid's".
![]() larry Last edited by timberbeast; 05-07-2014 at 03:15 AM. Reason: punctuation :) |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,170
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You're welcome
![]() |
![]() |
![]() |
![]() |
#7 |
stumblebum
![]() Posts: 29
Karma: 10
Join Date: Nov 2013
Location: Roseburg, OR
Device: kindle2
|
I'm on it. Thanks again, Kovid.
I went and added hypens to the newest re too. It picks up orphaned hyphens from the chop job too. The 'Replace and Find' button makes quick work of that mess now. I'm a happy camper. ![]() cheers, larry |
![]() |
![]() |
![]() |
#8 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 243
Karma: 44444
Join Date: Mar 2014
Device: Kindle PW2 special offers removed by Amazon for FREE
|
I'm just warning you, that one day you wont be able to distinguish one saved search from another. DONT USE THAT NAMING CONVENTION IT'S DANGEROUS.
![]() ![]() ![]() ![]() ![]() Thanks kovidgoyal for making this post possible. ![]() ![]() ![]() ![]() ![]() Last edited by user743; 05-08-2014 at 08:08 AM. |
![]() |
![]() |
![]() |
#9 | |
stumblebum
![]() Posts: 29
Karma: 10
Join Date: Nov 2013
Location: Roseburg, OR
Device: kindle2
|
Quote:
![]() Nah, by the time I forget those, I'll be able to write my own, and won't need 'em. ![]() I'm fascinated by regexs, and what you can do with them. Especially the lookaheads and the lookbehinds. I'm slooowly figuring how they work, and which to use, and when. [As a side note:] I had downloaded several applications to test regexs as learning tools. At least the Linux ones I could find. Then it came to me as I was using the Edit Book feature in Calibre. I told my self, "Self, you are a dumbass. One of the best testing applications in the world, for what you do, is right in front of your face! You don't need any of those others." ![]() Cheers, larry |
|
![]() |
![]() |
![]() |
#10 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Another resource for learning regex, which is more readable IMHO: http://www.regular-expressions.info
|
![]() |
![]() |
![]() |
#11 |
stumblebum
![]() Posts: 29
Karma: 10
Join Date: Nov 2013
Location: Roseburg, OR
Device: kindle2
|
Thanks eschwartz, I'll check it out. Any thing I can get my grubby paws on about regexs is highly appreciated.
larry |
![]() |
![]() |
![]() |
Tags |
editor, html tags, regex |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Consumers Don't Mind...Ads." Really? | L.J. Sellers | General Discussions | 116 | 05-29-2011 06:39 AM |
Which Ones DON'T have an internet browser? Don't require a bookstore account? | emellaich | Which one should I buy? | 10 | 01-28-2011 02:50 AM |
$99? - Never mind that | Zach | Sony Reader | 315 | 10-18-2007 07:11 AM |