06-10-2013, 10:28 PM | #1 |
Groupie
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. |
06-10-2013, 10:54 PM | #2 | |
Well trained by Cats
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:
Code:
<p>(.([A-Z]| ){4,10}) the trailing comma in the range says or more if you don't want a finite cap. |
|
Advert | |
|
06-11-2013, 07:02 AM | #3 |
Groupie
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 |
06-11-2013, 08:41 AM | #4 | |
Well trained by Cats
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:
Code:
<p.*>(.([A-Z]| ){4,10}) |
|
Tags |
regex |
|
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 |