Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 07-15-2019, 01:02 PM   #1
nbveh
Junior Member
nbveh began at the beginning.
 
Posts: 8
Karma: 10
Join Date: May 2011
Location: Stockholm
Device: TrekStor Pyrus mini
reg.expr: how to detect the whole line?

Hi!


i have this sort of header on every page:

<p class="calibre1"> BAD WRITING AND HOWTO FIX IT</p>

So i need to detect a line where all the characters are capital letters and there's always more than one word. I also need to make sure that the script wouldn't delete similar strings inside of the text which is NOT header.

Is there someone who could help me with it please? So far i've figured out how to detect strings of capital characters: [A-Z]{2,} and tried to use () to repeat the pattern search but just got all confused...

nbveh is offline   Reply With Quote
Old 07-15-2019, 01:47 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,817
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
You only want lines with all Capitals (with space)?
I think this will work, but BE CAREFUL. it may grab titles
CASE SENSITIVE ticked
Code:
<p class=".+">(\s*[A-Z]){1,}</p>
<< repetition 1 to infiniity
theducks is offline   Reply With Quote
Advert
Old 07-15-2019, 06:23 PM   #3
nbveh
Junior Member
nbveh began at the beginning.
 
Posts: 8
Karma: 10
Join Date: May 2011
Location: Stockholm
Device: TrekStor Pyrus mini
thanks!

It works almost perfectly, except:

it detects this kind of lines: <p class="calibre1"> I</p>

It detects lines with one word only.

Can i somehow limit is to choose like where there's more than one word? And more than one character?

Again, thanks a lot, i'll try to understand how it all works!
nbveh is offline   Reply With Quote
Old 07-15-2019, 07:57 PM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,817
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by nbveh View Post
thanks!

It works almost perfectly, except:

it detects this kind of lines: <p class="calibre1"> I</p>

It detects lines with one word only.

Can i somehow limit is to choose like where there's more than one word? And more than one character?

Again, thanks a lot, i'll try to understand how it all works!
The expression is looking for (in order):
(
a optional space (the * says 0 or more)
Upper case letters (The case sensitivity affects this)
)
Repeat the pattern 1,to many times
So make 2 changes
Code:
<p class=".+">(\s*[A-Z][A-Z]){2,}</p>
It requires at least 2 consecutive words (with optional leading space)
But this has the bad effect of missing ANY 1 letter word .
You might run this one first, the run the original on MANUALLY as the number of hits should be greatly reduced.

BTW I ASSUME, you are using the Editor, not trying to do this as part of a conversion
theducks is offline   Reply With Quote
Old 07-15-2019, 10:45 PM   #5
nbveh
Junior Member
nbveh began at the beginning.
 
Posts: 8
Karma: 10
Join Date: May 2011
Location: Stockholm
Device: TrekStor Pyrus mini
Quote:
Originally Posted by theducks View Post
BTW I ASSUME, you are using the Editor, not trying to do this as part of a conversion

Hehe, that's exactly what i was doing but i was wondering how to have more control over what's getting replaced and what not, i'll try the editor!

thanks a lot!
nbveh is offline   Reply With Quote
Advert
Reply

Tags
regular expressions


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Title or Author Correction via Reg Ex?? gsd2012 Library Management 10 07-09-2018 09:44 AM
Help with Reg-ex of Course pappabees61 Library Management 1 09-23-2017 09:34 PM
Reg-ex help...? ElMiko Sigil 11 12-06-2011 12:41 AM
Adobe Reg problem on PE Gremalkin enTourage eDGe 5 09-02-2011 03:01 PM
Reg expression for importing Debby Library Management 2 02-17-2011 11:20 AM


All times are GMT -4. The time now is 05:17 PM.


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