6
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 3 years have passed since last update.

タグの中身だけ取り出したい正規表現

Posted at

たとえば、

<div>aaaaa</div>

このdivの中身だけ取り出したい場合に使う正規表現は

/(?<=<div>).*?(?=<\/div>)/

###(?<=

これは、肯定的後読みという
わかりやすく書くと、

(?<= aa )
直前にaaがあるということ

###(?=<

これは肯定的先読みという
わかりやすく書くと

(?=< aa )
直後にaaがあるやつ

なので(?<=<div>).*?(?=<\/div>)
<div>の直後で、</div>の前にあるやつってかんじ 

6
2
0

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
6
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?