Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列があるとしましょう:
"Joe Doe is not here"
この文字列を複数の空白でのみ分割し、Joe Doe を 1 つの部分文字列として保持したいと考えています。
結果は次のようになります。
string[] result={"Joe Doe","is","not","Here"}
パターンとして@"\s {2、}"を指定したRegex.Splitを使用します。これにより、空白文字が2つ以上ある場合は常に分割されます。
Regex.Split(input, @"\s{2,}")
この正規表現には最小が必要です。2スペース。