2016-10-25 26 views
0

私はコミットメッセージを取得するために、Webページをスクラップするシェルスクリプトを作成しています。それは次のようになります取得出力:sedを使用したhtmlタグの削除

Fix function <code>something_or_other()</code>, with a helpful fix from <a href="https://somewebsite.com">somebody</a>. <br> 
Also, fix <a href=somewhere>another thing</a> 

そして、私は出力これにスクリプトをしたいと思います:

Fix function something_or_other(), with a helpful fix from somebody. Also, fix another thing. 

正規表現とは別にこれを行う方法はありますか?私は、正規表現を使用してHTMLを解析するdangersをよく知っていますが、これは唯一のオプションのようです。あまりにも多くの非ユビキタスな外部プログラム(例えば、GNU sedが使われていますが、POSIX sedはうまくいきません)をあまり使わない方がいいです。

+0

http://stackoverflow.com/documentation/command-line/7613/parsing-html-using-xmllint-on-a-unix-like-terminal#t = 201610270431550442455進行中の作業です。解析しているhtmlの例を投稿した場合は、堅牢なソリューションを見つける手助けをしても構いません。 –

答えて

0
echo 'Fix function <code>something_or_other()</code>, with a helpful fix from <a href="https://somewebsite.com">somebody</a>. <br> 
Also, fix <a href=somewhere>another thing</a>' | sed -r s/\<[^\>]+\>//g | sed 'N;s/\n/ /' 

出力:

Fix function something_or_other(), with a helpful fix from somebody. Also, fix another thing 
関連する問題