Reputation: 19
Hi everybody i try to create a script which modify string inside html files.
I want to edit this line:
<a class="ABC" href=/photos/albums">
I want replace "ABC" by "test" - the problem is that the name of the class is not always ABC it can change by a random name but there is always href=/photos...
Is it possible to replace the random name of class by test?
Thans for help.
Upvotes: 0
Views: 100
Reputation: 174756
Through GNU sed,
$ sed -r 's~(<a\s*class=")([^"]*)("\s*href=/photos)~\1test\3~g' file
<a class="test" href=/photos/albums">
Changed the sed delimiter only because of forward slashes in your input.
Upvotes: 1