Java の Regex について簡単な質問があります (他の言語もおそらく同様ですが)。
私がやろうとしているのは、次のように文字列を変換することです:
How are you "Doing well" How well 10 "That's great"
//# I want the Regex in Java to match out all of the words, numbers,
//# and things inside quotation marks. Ideally, I'd get something like this
How
Are
You
"Doing Well"
How
Well
10
"That's Great!"
私が使用しようとしている正規表現は次のとおりです。
String RegexPattern = "[^"+ // START_OR: start of line OR"
"\\s" + // empty space OR
"(\\s*?<=\")]" + // ENDOR: preceeded by 0 or more spaces and a quotation mark
"(\\w+)" + // the actual word or number
"[\\s" + // START_OR: followed by a space OR
"(?=\")" + // followed by a quotation mark OR
"$]"; // ENDOF: end of line
ただし、これはうまくいきません。はるかに単純な文字列でも!ここで同様の問題を探すのに多くの時間を費やしました。引用符が必要ない場合は、分割を使用できます。ただし、最終的には、このパターンはさらに複雑になるため、正規表現を使用する必要があります (これは最初の反復にすぎません)。
助けていただければ幸いです。前もって感謝します!