Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

 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

like image 655
Debankan Avatar asked Mar 15 '26 08:03

Debankan


1 Answers

Using sed

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

Output

head For the Most Complex Heroines Animation
head The Psychology Behind Sibling
like image 59
HatLess Avatar answered Mar 17 '26 16:03

HatLess



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!