Thread: Regex examples
View Single Post
Old 08-18-2022, 02:48 PM   #726
CubGeek
Connoisseur
CubGeek began at the beginning.
 
Posts: 52
Karma: 10
Join Date: Sep 2021
Location: Upstate NY, USA
Device: iPad Pro, Kindle basic
Okay, after reading the <i>, <em> or <span> for italics thread from 2020, and then reading the Extended <head> chapter: NOT necessary? 2017 thread linked therein [and paying particular attention to Tex2002ans posting about the underlying purposes for <em> and <i> <em>therein</em> () ], I've seen the error of my ways regarding using <span> for setting italics.
  1. The up side: I've only just started dipping my toes into the waters with converting my documents into ePub format, so I'm learning good things!
  2. The down side: I now need to learn Regex to be able to search through the files to correct my earlier <span class="abuse">. Thanks, karma.

I've figured out that
Code:
<span class="italics">([^>]+)</span>
will catch every instance of the offending tags on both sides of the content so affected. However, I can't seem to figure out how to get the REPLACE function to leave the content alone and replace <em>just</em> the tags themselves.

I'm happy to do the legwork and the trial-and-error to learn what works. I guess my search skills also need an update, too, because the results I am turning up don't seem to work for me. Can someone help point me in the right direction?

[edit] Okay, I THINK I found it, but it was hit-or miss, because it seemed that everything was for Javascript/C##/VB.net/PHP/ruby/etc. so, it seems that some trial-and-error resulted in me learning about <i>backreferences</i> and <i>capture groups</i>. I've gotten it to work so that
Code:
<em>\g<1></em>
works. whew.

Okay, next question: is this a kludge and there's a better way? or is this correct? Thanks, y'all! [/edit]

Last edited by CubGeek; 08-18-2022 at 03:22 PM.
CubGeek is offline   Reply With Quote