私のファイルには次のような行が含まれています
"This is a string." = "This is a string's content."
" Another \" example \"" = " New example."
"My string
can have several lines." = "My string can have several lines."
部分文字列を抽出する必要があります:
This is a string.
This is a string's content.
Another \" example \"
New example.
My string
can have several lines.
My string can have several lines.
これが私のコードです:
String regex = "\".*?\"\\s*?=\\s*?\".*?\"";
Pattern pattern = Pattern.compile(regex,Pattern.DOTALL);
Matcher matcher = pattern.matcher(file);
今のところ、「=」の左右の部分のペアを取得できます。しかし、サブストリングに「\」が含まれていると、正規表現が正しく機能しません。
誰かが正しい正規表現を書くのを手伝ってもらえますか?\"の代わりに\"^[\\ "]を試しましたが、うまくいきませんでした。
よろしくお願いします。