%20%E3%82%92%E5%89%8A%E9%99%A4%E3%81%97%E3%81%BE%E3%81%99%20(%E6%96%87%E5%AD%97%E5%88%97%E3%81%8B%E3%82%89).png)
この HTML タグ (文字列から) があります:
<meta name="description" content="I love my mother" but I love my sister" more than I can say"/>
ご覧のとおり、二重引用符(アポストロフィ)が4つあります。コンテンツセクション。二重引用符は先頭content="
と末尾の2つだけにしてください。"/>
コンテンツ セクションの 2 つの二重引用符を除く他の二重引用符を含むすべてのタグを見つけて削除する必要があります。
出力は次のようになります。
<meta name="description" content="I love my mother but I love my sister more than I can say"/>
正規表現を作成しましたが、あまり良くありません。助けていただけないでしょうか:
探す:(?-s)(<meta name="description" content=")(*?\K.*"(?s))"/>
置き換え:\1\2
答え1
方法は次のとおりです:
- Ctrl+H
- 検索対象:
(?:<meta name="description" content="|\G(?!^))[^"]*\K"(?=.*?"/>)
- と置換する:
LEAVE EMPTY
- チェック 包み込む
- チェック 正規表現
- チェックを外す
. matches newline
- Replace all
説明:
(?: # non capture group
<meta name="description" content=" # literally
| # OR
\G(?!^) # restart from last match position (not at the beginning of a line)
) # end group
[^"]* # 0 or more non quote
\K # forget all we have seen until this position
" # a double quote
(?=.*?"/>) # positive lookahead, make sure we have "/> somewhere after
スクリーンショット(前):
スクリーンショット(後):