我的問題是,我有一個字符串,我想將它拆分成一個數組。例如:將文本和服務器路徑的字符串拆分爲數組
我得到的字符串是
Unexpected Error: Check Availability of Data Source Failed:
\\server01\z.storage\Folder\Folder\Folder\Folder\_Folder\Folder_3\Folder\Folder\File_Fi_3.expression
missing.
\\server01\z.storage\Folder\Folder\Folder\Folder\_Folder\Folder_F6\Folder\Folder\File1_Fi_F2.expression
missing. \\server01\z.storage\Folder\Folder\Fo\Folder With
Spaces\_Folder\Folder_F6\Folder\Folder\File123.expression missing.
Details can be found on the Server at :
\\server01\p.programming\Software
Unit\01_Projects\Folder\Folder-FO-Fol\Folder\Folder_ErrorLog\Folder\Folder
With Spaces\Log\
現在,我會得到一個數組至極看起來是這樣的:
ArrayName[0] = "Unexpected Error: Check Availability of Data Source Failed: "
ArrayName[1] = "\\server01\z.storage\Folder\Folder\Folder\Folder\_Folder\Folder_3\Folder\Folder\File_Fi_3.expression"
ArrayName[2] = " missing."
ArrayName[3] = "\\server01\z.storage\Folder\Folder\Folder\Folder\_Folder\Folder_F6\Folder\Folder\File1_Fi_F2.expression"
ArrayName[4] = " missing."
ArrayName[5] = "\\server01\z.storage\Folder\Folder\Fo\Folder With Spaces\_Folder\Folder_F6\Folder\Folder\File123.expression"
ArrayName[6] = " missing."
ArrayName[7] = "Details can be found on the Server at : "
ArrayName[8] = "\\server01\p.programming\Software Unit\01_Projects\Folder\Folder-FO-Fol\Folder\Folder_ErrorLog\Folder\Folder With Spaces\Log\"
我tryed它由string.Split分裂,但我得到的文件夾路徑中包含空格的字符串,並且傳入的字符串不會每次都有4個服務器路徑......它可以更多或更少。也許有人可以幫助我:O)
分裂究竟你想成爲splited數組是什麼? –
你試過根據\ r \ n –
進行拆分這將是很好的例子,你想獲得輸出結果 –