Regex html中标记之间的搜索模式

Regex html中标记之间的搜索模式,regex,bash,sed,grep,Regex,Bash,Sed,Grep,我需要从具有特定标题的标记中获取值 我有这个命令 sed -n 's/title="view quote">\(.*\)<\/a>/\1/p' index.html sed-n's/title=“view quote”>\(.*\)/\1/p'index.html 这是index.html的一部分,我需要“生活中的一切都是运气” <a title="view quote" href="https://www.b

我需要从具有特定标题的标记中获取值

我有这个命令

sed -n 's/title="view quote">\(.*\)<\/a>/\1/p' index.html
sed-n's/title=“view quote”>\(.*\)/\1/p'index.html
这是index.html的一部分,我需要“生活中的一切都是运气”

    <a title="view quote" href="https://www.brainyquote.com/quotes/donald_trump_106578" class="oncl_q">
<img id="qimage_106578" src="./Donald Trump Quotes - BrainyQuote_files/donaldtrump1.jpg" class="bqphtgrid" alt="Everything in life is luck. - Donald Trump">
</a>
</div>
<a href="https://www.brainyquote.com/quotes/donald_trump_106578" class="b-qt qt_106578 oncl_q" title="view quote">Everything in life is luck.</a>
<a href="https://www.brainyquote.com/quotes/donald_trump_106578" class="bq-aut qa_106578 oncl_a" title="view author">Donald Trump</a>
</div>


我需要所有这些符来填充bash中的数组。

您的sed命令基本上是好的-只是在regex的每一端缺少了
*
,以删除额外的头和尾

此命令提取具有特定标题的所有值:

sed -n 's/.*title="view quote">\(.*\)<\/a>.*/\1/p' index.html
sed-n's/*title=“view quote”>\(.*\)./\1/p'index.html
要放入数组,请执行以下操作:

IFS=$'\n' array=( $(sed -n 's/.*title="view quote">\(.*\)<\/a>.*/\1/p' index.html) )
IFS=$'\n'数组=($(sed-n's/*title=“view quote”>\(.*\)./\1/p'index.html))
要验证结果数组,请执行以下操作:

for ((i=0;i<${#array[@]};i++)); do
    echo ${array[$i]}
done
for((i=0;i
mapfile-t数组<