View Single Post
Old 11-30-2011, 06:46 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: 30,891
Karma: 60358908
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 ElMiko View Post
So I've now run into this problem twice. Hopefully, the reg-ex wizards among you will have a head-slappingly simple solution to my problem.

First Case
Every new paragraph is formatted as:
Code:
<p class="calibre2"><span class="none">A Bunch of Text</span></p>
I want to change the "p class" to "calibre5" for Chapter headings only, which are currently formatted like this (1., 2., 3., ..., 21., 22., etc):
Code:
<p class="calibre2"><span class="none">1.</span></p>
Finding all the instances with reg-ex is easy enough by search for:
Code:
<p class="calibre2"><span class="none">([0-9]+\.)</span></p>
But that's as far as I can get. Replacing the above with:
Add the Red
Quote:
Code:
<p class="calibre5"><span class="none">\1</span></p>
Now make the replace look like the above:
The red \1 is the found value inside the ( ) above

changes the number to "[0-9]+\."!

Second Case
In another book, there are random paragraph breaks mid-sentence.
My solution to that would be to find all the new paragraphs that begin with a lower-case letter, and replace all the code between it and the previous paragraph. Again, finding the instances via reg-ex proved pretty intuitive:
Code:
</p>[\s]+<p class="calibre2">([a-z])
But again, i just can't figure out how to alter the code (in this case replacing it with a blank space) without altering the first letter of the first word in that paragraph.
[/QUOTE]
the replace is: (space)\1
Quote:
Looking over what I've written, I am humbled by how utterly inarticulate this all sounds, but if someone understands my gibberish, I'd be most grateful for any light you could shine on my problem.
theducks is online now   Reply With Quote