![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Is there RegEx to <span> ALL CAPS text?
RegEx question:
There's lot of text in all caps in something I'm trying to reformat. Doesn't really hurt, but I'd like to set it off somehow. I've been trying to come up with a reg expression that would bracket the UC text with <span> tags, something like below, and then I could make a simple class to set the UC text off somehow ... The Before: Code:
<p>"AAAAAA BBBBBB CCCCCC, DDDDD EEEEE," he said, FFFFF GGGGG HHHHH. Zzzzzz yyyyy xxxxx.</p> The (hopefully) After: Code:
<p><span class="incaps">"AAAAAA BBBBBB CCCCCC, DDDDD EEEEE," </span> he said, <span class="incaps">FFFFF GGGGG HHHHH.</span> Zzzzzz yyyyy xxxxx.</p> Couple of things that I noticed: 1. in EEEEE," he said, FFFFF ... the he said, is 'normal' 2. In HHHHH. Zzzzzzz ..... the cap Z is 'normal' Thanks for any help Paul |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
You could do something along these lines:
Search: Code:
([A-Z][A-Z,"\. ]+ [A-Z]{2,}) Code:
<span class="incaps">\1</span> The Blue section will always be looking for a space followed by two more capitals, and will fail when it does NOT see "a space and 2 or more capitals in a row". This will match: Code:
<p>"AAAAAA BBBBBB CCCCCC, DDDDD EEEEE," he said, FFFFF GGGGG HHHHH. Zzzzzz yyyyy xxxxx.</p> |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
Tex2002ans --
1. Thanks for the answer -- works great 2. And thanks for the explaination. Helps me to understand 3. And now .... a slight change to requirements ![]() My fault -- your S&R works perfectly but it also changes things like this. Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> into Code:
<!DOCTYPE html PUBLIC "-//W3C//<span class="incaps">DTD XHTML</span> 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> I exerpimented with RegEx changes using !(<!) but no joy. I also tried a 2 pass approach: your S&R, and then another S&R to un-do the Code:
<span class="incaps">DTD XHTML</span> Paul |
![]() |
![]() |
![]() |
#4 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
![]() Although if you still wanted to be lazy and Replace All. I can recommend changing Sigil to Replace in the "Current File", direction set to "Down", and turning off "Wrap". Then you can click below the header information, and then press Replace All, and do this for each file in the book you want the span added to. |
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
You gave me 99% of what I needed, so the other 1% will not be a problem
I think I'll go with the 'two pass' approach, and run a second S&R to tweak the doc headers That'll be easier for me to maintain anyway when I have to add some of my other forgots Thanks again Paul |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regex and span | JSWolf | Sigil | 7 | 01-23-2013 06:35 AM |
python regex: delete text in preprocessing | sws | Recipes | 0 | 01-11-2013 09:01 AM |
Regex problem: Trying to replace surrounding text without effecting the middle | ghostyjack | Workshop | 3 | 10-09-2012 04:26 PM |
Help with regex expression for words in all caps | bfollowell | Sigil | 9 | 01-20-2012 05:11 PM |
how do I span more than one line with regex | BartB | Sigil | 3 | 12-11-2011 05:12 PM |