1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Golangで文字列からタグを取り除く方法

Last updated at Posted at 2016-02-16

Golangで文字列からタグを取り除く方法

タグを抜き出して表示をしたい場合があります。
そんな時は正規表現を使ってうまく取り除くことができます。

removeTag
func removeTag(str string) string {
    rep := regexp.MustCompile(`<("[^"]*"|'[^']*'|[^'">])*>`)
    str = rep.ReplaceAllString(str, "")
    return str
}
1
2
2

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?