Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 03-09-2013, 09:39 PM   #1
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,071
Karma: 412718
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>
Or at least that's what I think I want, but I'm open to suggestions.

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
phossler is offline   Reply With Quote
Old 03-10-2013, 03:32 AM   #2
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
You could do something along these lines:

Search:

Code:
([A-Z][A-Z,"\. ]+ [A-Z]{2,})
Replace with:

Code:
<span class="incaps">\1</span>
The Red section of the Regex will grab the first capital letter, followed by all caps, commas, quotations, and periods.

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>
Tex2002ans is offline   Reply With Quote
Advert
Old 03-10-2013, 09:56 AM   #3
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,071
Karma: 412718
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 can use the [Find/Replace] button if I have to, but it is a little tedious

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>
Is it possible to avoid changing things like the example in the first place??


Paul
phossler is offline   Reply With Quote
Old 03-10-2013, 01:50 PM   #4
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by phossler View Post
Is it possible to avoid changing things like the example in the first place??
Sometimes you just can't use a Regex with Replace All, because you might catch a few false positives. Sadly I do not know off the top of my head a way to catch everything else..... perhaps looking for that match only while it is inside of <p> tags.... but now you are making my head hurt.

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.
Tex2002ans is offline   Reply With Quote
Old 03-10-2013, 02:43 PM   #5
phossler
Wizard
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 1,071
Karma: 412718
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
phossler is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:26 AM.


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