View Single Post
Old 12-31-2014, 10:29 AM   #17
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,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Thanks for your patience and the explanations


Quote:
You need to specify a group that matches the actual content, like this.
Thanks - I'm a little smarter about RegEx now.

Using your Find works exactly as advertised and it correctly finds and highlights the Hx tags.


Quote:
The built in functions won't do that, because, they are for general purpose use, not specifically for changing text between tags.
Understand, but it still seems (to me at least) that there is a possible side effect of the built in TitleCase function


1. It replaces tag markers ('<' and '>') with what is treated like normal text
2. It does not TitleCase the text that it does find


Quote:
'''Title-case matched text. If the regular expression contains groups,
only the text in the groups will be changed, otherwise the entire text is
changed.'''

So I assume that

<[Hh][1-6]>(.+?)</[Hh][1-6]>

would make the \1 group for the Replace just the red text in the Before below?

Before:

Code:
  <h1>TEST1 TEST1 TEST1 TEST1 TEST1 </h1>
  <p>NOW IS THE TIME and this should remain mixed case</p>
  <h1>TEST2 TEST2 TEST2 <br/><br/>TEST3 TEST3 </h1>
  <p>NOW IS THE TIME and this should remain mixed case</p>
  <h1>TEST4 <i>TEST4 TEST4 TEST4</i> TEST4 </h1>

After:

Code:
 <h1>Test1 Test1 Test1 Test1 Test1 </h1>
  <p>NOW IS THE TIME and this should remain mixed case</p>
  <h1>TEST2 TEST2 TEST2 &lt;br/&gt;&lt;br/&gt;TEST3 TEST3 </h1>
  <p>NOW IS THE TIME and this should remain mixed case</p>
  <h1>TEST4 &lt;i&gt;TEST4 TEST4 TEST4&lt;/i&gt; TEST4 </h1>
1. So the simplest case (first H1) works correctly

2. I don't understand why the same logic isn't applied to the second and third so that all text between the Hx's is made title case, as well as why the replacement of < and > with entities which end up being treated like normal text
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	271
Size:	120.2 KB
ID:	133162  
phossler is offline   Reply With Quote