二重引用符で囲まれたすべての二重引用符をエスケープしたいとします (CSV などを想像してください)。
"Jim", "Smythe", "Favorite Quote: "This is my favorite quote.""
This is my favorite quote.
を囲む内側の引用符を分離し、. でエスケープしたいと思い\
ます。しかし、内側の引用符で一致する正規表現を書くのに苦労しています。したがって、私が望む結果の一致は次のとおりです。
"Jim", "Smythe", "Favorite Quote: "This is my favorite quote.""
^^ ^^
Start Match Here || || End Match Here
Start Capture Here | End Capture Here |
Match: "This is my favorite quote."
Capture: This is my favorite quote.
そして、パターン\"$1\"
を使用して引用符を簡単にエスケープして、最終結果を取得できます。
"Jim", "Smythe", "Favorite Quote: \"This is my favorite quote.\""