字符串我有一個字符串等如下所示:拆分用逗號和結腸
var String = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string without comma,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string,with comma,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string without comma,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string , with comma,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:String,with comma"
凡xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
代表一個字母數字生成的ID和冒號後是與該Id.The字符串的字符串可以是一個逗號或沒有逗號的字符串。我想要的是我想分割字符串,以便得到一個ID爲ID的數組:它的對應字符串,如下所示。
["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string without comma","xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string,with comma","xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string","xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string without comma", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:some string , with comma","xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:String,with comma"]
HOW我完成了這一
我使用的JavaScript split函數,其中i由分割逗號字符串後跟36個字符(ID)和結腸。 PS:我很抱歉,因爲我以前無法以正確的方式提問。希望這次人們能夠理解它。
請添加一個有效的結果。 –
*是否可以使用javascript?* **是**。你可以分享你嘗試過的嗎? – Rajesh
@Rajesh我嘗試使用 「.split(/:|,/)」 ..但沒有得到它的權利 – talentedandrew