Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 06-10-2013, 10:28 PM   #1
Hoods7070
Groupie
Hoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notes
 
Posts: 159
Karma: 24430
Join Date: Mar 2012
Location: Australia
Device: Nexus 7"
Help with Regex - find groups of words in uppercase

I want to be able to find groups of text all in uppercase (and any punctuation etc. in those groups) in my books then span the groups with a style. e.g. Find THE CAT SAT, ON THE-MAT, Replace same string with a span of Style tags around it.

I can easily single uppercase words, but I have no idea how to extend that search to include more than one word. Any help with that, and the code for the Replace would be greatly appreciated.
Hoods7070 is offline   Reply With Quote
Old 06-10-2013, 10:54 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,791
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 Hoods7070 View Post
I want to be able to find groups of text all in uppercase (and any punctuation etc. in those groups) in my books then span the groups with a style. e.g. Find THE CAT SAT, ON THE-MAT, Replace same string with a span of Style tags around it.

I can easily single uppercase words, but I have no idea how to extend that search to include more than one word. Any help with that, and the code for the Replace would be greatly appreciated.
I used this search for an all CAPs new scene detect
Code:
<p>(.([A-Z]| ){4,10})
your search wants to detect a minimum count of CAPS (say {3,} ), followed by a space, repeated at least {4,} times
the trailing comma in the range says or more if you don't want a finite cap.
theducks is offline   Reply With Quote
Advert
Old 06-11-2013, 07:02 AM   #3
Hoods7070
Groupie
Hoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notesHoods7070 can name that song in three notes
 
Posts: 159
Karma: 24430
Join Date: Mar 2012
Location: Australia
Device: Nexus 7"
Thanks, Ducks, that works to a degree, minus the <p> tag. I removed the <p> tag and added a space before ( .([A-Z) and that works well enough to find groups. Unfortunately it also finds single words all in uppercase (e.g. the all caps stuff in the !DOCTYPE codes at the top of each page) but I can live with that.

Cheers
Hoods7070 is offline   Reply With Quote
Old 06-11-2013, 08:41 AM   #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,791
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 Hoods7070 View Post
Thanks, Ducks, that works to a degree, minus the <p> tag. I removed the <p> tag and added a space before ( .([A-Z) and that works well enough to find groups. Unfortunately it also finds single words all in uppercase (e.g. the all caps stuff in the !DOCTYPE codes at the top of each page) but I can live with that.

Cheers
That is why the <p was there (it did need some fine tuning to closer match your usage style) These are kickstart tips, not absolutes, you are expected to season to taste


Code:
<p.*>(.([A-Z]| ){4,10})
might work better IF you code uses P and not DIV <--see! Why season to taste is needed
theducks is offline   Reply With Quote
Reply

Tags
regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex find and replace SanatyrZeo Sigil 5 10-29-2012 07:03 AM
Help with regex expression for words in all caps bfollowell Sigil 9 01-20-2012 05:11 PM
RegEx find and replace iblesq Sigil 1 01-10-2011 09:26 PM
regex to fix up hyphenated words please cybmole Sigil 2 01-06-2011 04:13 AM
REGEX find and replace help please potestus Sigil 13 09-18-2010 04:14 PM


All times are GMT -4. The time now is 04:15 AM.


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