LoginSignup
171
153

More than 5 years have passed since last update.

JavaScriptでHTMLタグを削除する正規表現

Last updated at Posted at 2013-11-21

RSSを引っ張ってきて表示する時にテキストだけ取得したくて、データに含まれているHTMLタグを削除したかった。
メモ。

var str = '今日は<strong>とても</strong>良い天気<br />だと思うよ?<img src="" alt="" />';
console.log(str.replace(/<("[^"]*"|'[^']*'|[^'">])*>/g,''));

今日はとても良い天気だと思うよ?

ちゃんと出た!(^o^)丿

171
153
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
171
153