我有2個字符串,我想對他們使用String.Split()
方法,如果字符串中包含「愛你」,我想要做的是忽略空間並將其保存在數組中作爲一個元素然而,如果它包含「愛」僅保存正常vb.net字符串與規則拆分
str1 = "I Love Her"
str2 = "I Love You Not"
'no problem with splitting the first string
Dim strsplit1() As String = str1.Split(New String() {" "}, StringSplitOptions.None)
對於第二string..how我可以忽略的空間分離器和「愛你」另存爲一個元素?
請注意,這僅僅是一個例子,我的心靈告訴我檢查indexofLove + 1,但我怎樣才能得到愛的指數?!
右圖像你甚至可以改進這個解決方案(如果你的數據中有真正的「Love_You」字符串)。將「Love You」替換爲「Love」&ChrW(17)&「You」,因爲ChrW(17)絕對不是文字符號。 – Dima