Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Replacing html content using sed and regex

I am trying to replace the content of some HTML content using sed in a bash script. For some reason I’m not getting the proper result as it’s not replacing anything mainly the regex part

HTML i want to replace

<h3 class="indicate-hover css-5fzt5q">For the Most Complex Heroines Animation
<h3 class="indicate-hover css-1pvrrwb">The Psychology Behind Sibling

to

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 head For the Most Complex Heroines Animation
 head The Psychology Behind Sibling

i used

  sed -e 's/<h3 class="indicate-hover css-([a-b0-9]+)">/head/g'

mainly ([a-b0-9]) this part is getting failed in execution , i must be missing something out,i want to get it more specific , i have "<p class="summary-class css-1azn4ub">How many words can" i want to substitute it to ‘tail ‘ and have many more other tags . The regex part is giving me the pain

>Solution :

Using sed

$ sed 's/.*-[[:alnum:]]\+">/head /' input_file

Output

head For the Most Complex Heroines Animation
head The Psychology Behind Sibling
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading