「我有下面的字符串..以‘#’的VBScript:度假村串並組新的拆分項
myStr = "78,6$25,01|25,02|25,03|25,04#74,5$15,01|15,02|15,03|15,04#70,1$25,06|25,07|25,08|25,09#77,3$25,07|25,08|25,09|25,10#78,2$10,05|10,06|10,07|10,08"
splited」,我想再打這與新字符串新的分組...
「我應該組splited字符串以美元($)chrachter後第一個值
但我不ķ我現在應該怎麼排序和分組到新的期望結果:
myStrDesired = "78,2$10,05|10,06|10,07|10,[email protected],5$15,01|15,02|15,03|15,[email protected],6$25,01|25,02|25,03|25,04#70,1$25,06|25,07|25,08|25,09#77,3$25,07|25,08|25,09|25,10"
我的腳本:
Function GroupArrays()
myStr = "78,6$25,01|25,02|25,03|25,04#74,5$15,01|15,02|15,03|15,04#70,1$25,06|25,07|25,08|25,09#77,3$25,07|25,08|25,09|25,10#78,2$10,05|10,06|10,07|10,08"
'And I want resort to this New String with New Grouping...
'i should group splited string with first value after dollar($) chrachter
myStrDesired = "78,2$10,05|10,06|10,07|10,[email protected],5$15,01|15,02|15,03|15,[email protected],6$25,01|25,02|25,03|25,04#70,1$25,06|25,07|25,08|25,09#77,3$25,07|25,08|25,09|25,10"
arrMyStr = Split(myStr,"#")
arrMyStrDesired = ""
for i = 0 to UBound(arrMyStr)
' find group id from each string
groupVal = Split(Split(arrMyStr(i),"$")(1),",")(0)
' put the same groups together and split them by "#" And finally the isolation of other disciplines with "@"
arrMyStrDesired = arrMyStrDesired & arrMyStr(i)
next
GroupArrays = arrMyStrDesired
End Function
新說明:*
斯普利特主串「#」號。
在splited每個零件......看到「$」,並將其命名爲「的groupId」後的第一個值。 (它是用於分組的重要參數和排序)
每個部件的所有具有相同的groupId應該由並排放置,並通過「#」加入。
上述步驟後......我們應該通過「@」與其他groupId加入所有新字符串....與...相同...(00 $ 01,05#01,06#... @ 02,07 @ 03,4 .....)
的答案是我的問題太辛苦? 我以爲我很初學。 – sadrasjd
我已經多次查看這個問題,並發現措辭相當混亂。我認爲* *您想拆就''#,用後'$'由價值決定的自定義排序順序生成的數組排序,然後用''#歸隊他們 - 但措辭非常模糊,如果這是你想要什麼。 –
@約翰·科爾曼:我很抱歉壞字眼...... PLZ看到功能 – sadrasjd