Sample Header Ad - 728x90

Edit inside an HTML tag with ed(1)

0 votes
3 answers
98 views
Consider my humble _hello.html_ file, edited with mighty ed:
$ ed hello.html 
28
,p
Hello world!
What's your general approach to edit inside that *title* HTML tag (bonus if you can edit inside any HTML tag)? I tried a regular expression that matches inside the tag:
s/>.*/>My new title/p
My new title
u
.
Hello world!
But, sadly, you can see that I chopped my tag (and it would be way too much work to type out that _``_ bit every time!). For further education, I browsed through Software Tools in Pascal page to 174—see https://archive.org/details/softwaretoolsinp00kern/page/174/mode/1up?view=theater page—and discovered the _&_ special character that helpfully reaches the _middle_ of the sentence:
s/world/& again/p
Hello world again!
But, that's not quite right, since I want to substitute the middle, not just reach the middle.
Asked by mbigras (3472 rep)
Feb 6, 2024, 06:22 AM
Last activity: Feb 6, 2024, 10:49 AM