On 06/28/2024 03:53 PM, Michael Kjörling wrote:
On 28 Jun 2024 14:04 -0500, from rowl...@access.net (Richard Owlett):
I need to replace ANY occurrence of
<span class="verse" id="V1">
thru [at most]
<span class="verse" id="V119">
by
<sup>
I'm reformatting a Bible stored in HTML format for a particular set of
vision impaired seniors (myself included). Each chapter is in its own file.
How do I open a file.
Do the above replacement.
Save and close the file.
Ignoring the question about Emacs
Emacs *CAN NOT* be ignored.
It is the _available_ editor known to be capable of handling regular
expressions.
and focusing on the goal (your
question otherwise is an excellent example of a XY question), this is
not something regular expressions are very good at.
HUH ??????????
However, since
it's presumably a once-only operation, I assume that you can live with
it being done in a suboptimal way in terms of performance.
In that case, assuming for simplicity that all the files are in a
single directory, you could try something similar to:
$ for v in $(seq 1 119); do sed -i 's,<span class="verse" id="V'$v'">,<sup>,g'
./*.html; done
I'll have to investigate sed further.
My project is not yet to the point of automatically editing ALL
chapters. I need to first establish how to edit all VERSES of an
individual chapter.
Be sure to have a copy in case something goes wrong; and diff(1) a few
files afterwards to make sure that the result is as you intended.
ROFL ;} No one would define me as a "programmer". I took an introduction
to computers course as a E.E. student in the 60's. Most of my jobs
required background in component level analog electronics. Got one
assignment because I was not "afraid" of 8080 ;}
Yes, it almost certainly can be done with a single sed (or other
similar tool) invocation where the regular expression matches
precisely what you want it to match. But unless this is something you
will do very often, I tend to prefer readability over being clever,
even if the readable version is somewhat less performant.