gpt4 book ai didi

linux - 使用 sed 和正则表达式替换 html 内容

转载 作者:行者123 更新时间:2023-12-05 05:38:57 25 4
gpt4 key购买 nike

我正在尝试在 bash 脚本中使用 sed 替换某些 HTML 内容。出于某种原因,我没有得到正确的结果,因为它没有替换任何东西,主要是正则表达式部分

我要替换的 HTML

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

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

我用过

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

主要是 ([a-b0-9]) 这部分执行失败,我一定是漏掉了什么,我想更具体一点,我有 "<p class="summary-class css-1azn4ub">How many words can"我想将其替换为“tail”并拥有更多其他标签。正则表达式部分让我很痛苦

最佳答案

使用sed

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

输出

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

关于linux - 使用 sed 和正则表达式替换 html 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72805436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com