I am a regular on StackOverflow, Guy Coder, and saw this question on the language-agnostic tag. I find the tag is a great place to show off what Prolog can do compared to other languages.
The problem is:
I have a couple of thousands of .html files and I need to search and replace a hardcoded server name to a relative path, but ONLY in the footer.
e.g.
<body>
<a href="http://hardcoded/something">This is ok</a>
... much more content here
<div class="footer">
<a href="http://hardcoded/something">Change this one</a>
</div>
</body>
Is there any tool to do this kind of search and replace?
I gave a proof of concept answer, almost ashamed to leave it up, but it was my first time parsing HTML with DCGs. Then I refined it some more into another answer.
Now I am looking at refining it more, looking at SWI-Prolog SGML/XML parser and possibly The library(http/html_write) library, but know that others here can do a much better job from which I can learn something.
Curious to see other Prolog and DCG solutions. No need to answer soon, as this is out of curiosity than need.
Regards,
Eric