2012-12-28 109 views
0

比方說,我有一個字符串,如function arg1 arg2 "arg3 is long"參數字符串

我怎麼能獲得

String[0] = "function" 
String[1] = "arg1" 
String[2] = "arg2" 
String[3] = "arg is long" 
+2

你想從那個例子中得到什麼輸出? – jozefg

+0

字符串[]與String [0] =「function」的內容; String [1] =「arg1」; etc – ixchi

+2

[正則表達式用於在不包含單引號或雙引號的情況下使用空格拆分字符串]的可能重複(http://stackoverflow.com/questions/366202/regex-for-splitting-a-string-using-space-when不包圍的單或雙) –

回答