正規表現について質問させてください。
html
1<blockquote class="instagram-media" data-instgrm-permalink="https://www.instagram.com/p/〇〇/" data-instgrm-version="8" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:8px;"> <div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding:50.0% 0; text-align:center; width:100%;"> <div style=" background:url(data:image/png;base64,〇〇/〇〇+〇〇/〇〇/〇〇/〇〇+〇〇+〇〇/〇〇+〇〇+〇〇/〇〇); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;"></div></div><p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="https://www.instagram.com/p/〇〇/" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">〇〇さん(@〇〇)がシェアした投稿</a> - <time style=" font-family:Arial,sans-serif; font-size:14px; line-height:17px;" datetime="2017-00-00T00:00:00+00:00">2017年0月0月0日午後0時0分PST</time></p></div></blockquote> <script async defer src="//www.instagram.com/embed.js"></script>
wordpressにてサイトを運営しているのですが、自作したあるRSSフィードにおいて、上記インスタグラムの埋め込みコードなどはそのフィード上で配信したくない場合があり、これを削除した記事フィードを作りたいと考えております。
アイテムを丸ごと消すのではなく、あくまでそのアイテム内の特定の部分のみを消したいのですが、
上記のようなインスタグラムの埋め込みタグを記事内で削除したい場合、正規表現の書き方がわからず困っております。
例えば
[igdel]埋め込みタグ[/igdel]
などのように特定のワードプレスショートコードで囲む場合、その中身だけを正規表現で消すコードを教えていただきたいです。
/[igdel]*?[/igdel]/s
など、正規表現チェッカーで色々試してみましたがダメでした。
厳密にいうとショートコードを使うわけではないのですが、上記の方法で指定した範囲をどんな要素でも消せるのが理想です。
html
1 2例 3 4<p>あいうえお</p> 5[igdel] 6<!--ここから消したい--> 7<blockquote>かきくけこ</blockquote> 8<script async defer src="//www.instagram.com/embed.js"></script> 9<!--ここまで消したい--> 10[/igdel] 11 12<p>さしすせそ</p> 13[igdel] 14<!--ここからも消したい--> 15<blockquote>たちつてと</blockquote> 16<script async defer src="//www.instagram.com/embed.js"></script> 17<!--ここまでも消したい--> 18[/igdel] 19
恐れ入りますがどうぞよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー