View Single Post
Old 08-12-2013, 02:44 PM   #4
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,549
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by automa View Post
Is there a way you can apply heading 1 on all of those paragraphs that begins with the word Chapter?
Regex is your friend here. You should learn the basics of it if you want to start automating stuff to your advantage.

Please don't use this blindly without having good backups (and I'm sure someone will find a more effective/safe way--that's the beauty of regex ) but something like:
Code:
<p([^>]+)>(.*?)Chapter(.*?)</p>
replaced with:
Code:
<h1\1>\2Chapter\3</h1>
might work. It will retain any ids/classes the paragraph might have, as well as any elements that may be in front of/behind "Chapter." Without seeing the code in question, it's always a bit of a crapshoot. Make sure you're in regex S&R mode and have the "DotAll" option checked and the "Minimum Match" option unchecked.

Even so, any legitimate paragraph with the word "Chapter" in it is going to get caught up as well.

If there's a question of case (chapter, Chapter, CHAPTER), simply tell regex to ignore case by preceding the expression with (?i):
Code:
(?i)<p([^>]+)>(.*?)Chapter(.*?)</p>

Last edited by DiapDealer; 08-12-2013 at 02:51 PM.
DiapDealer is offline   Reply With Quote