imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 18, 2012 #1 Hi, I have this string; 108-306-204.. How can I get: a = 108 b = 306 c = 204 ??
M Mahares Expert Licensed User Longtime User Oct 18, 2012 #2 Here it is: Code: Copy Dim strBeforeSplit As String strBeforeSplit="108-306-204" Dim strSplit() As String strSplit=Regex.Split("-",strBeforeSplit) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") 'returns: 108 306 204 Upvote 0
Here it is: Code: Copy Dim strBeforeSplit As String strBeforeSplit="108-306-204" Dim strSplit() As String strSplit=Regex.Split("-",strBeforeSplit) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") 'returns: 108 306 204
imgsimonebiliato Well-Known Member Licensed User Longtime User Oct 18, 2012 #3 Mahares said: Here it is: Code: Copy Dim strBeforeSplit As String strBeforeSplit="108-306-204" Dim strSplit() As String strSplit=Regex.Split("-",strBeforeSplit) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") 'returns: 108 306 204 Click to expand... It doesn't help me, because I need each value different time! Upvote 0
Mahares said: Here it is: Code: Copy Dim strBeforeSplit As String strBeforeSplit="108-306-204" Dim strSplit() As String strSplit=Regex.Split("-",strBeforeSplit) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") 'returns: 108 306 204 Click to expand... It doesn't help me, because I need each value different time!
M Mahares Expert Licensed User Longtime User Oct 18, 2012 #4 That is simple. All you need to do is equate your variables to the different array components like this: a=strSplit(0) b=strSplit(1) c=strSplit(2) Last edited: Oct 18, 2012 Upvote 0
That is simple. All you need to do is equate your variables to the different array components like this: a=strSplit(0) b=strSplit(1) c=strSplit(2)
paolofi Member Licensed User Longtime User Dec 3, 2012 #5 HI, why this works: Code: Copy Dim Valore As String Dim strSplit() As String Value = "6-03/12/2012-test" '<-------------- strSplit=Regex.Split("-",Value ) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") and this not? Code: Copy Dim Valore As String Dim strSplit() As String Value = "6|03/12/2012|test" '<-------------- strSplit=Regex.Split("|",Value ) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") the "|" symbol is reserved?. Regards Upvote 0
HI, why this works: Code: Copy Dim Valore As String Dim strSplit() As String Value = "6-03/12/2012-test" '<-------------- strSplit=Regex.Split("-",Value ) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") and this not? Code: Copy Dim Valore As String Dim strSplit() As String Value = "6|03/12/2012|test" '<-------------- strSplit=Regex.Split("|",Value ) Msgbox(strSplit(0) & " " & strSplit(1) & " " & strSplit(2),"") the "|" symbol is reserved?. Regards
NJDude Expert Licensed User Longtime User Dec 3, 2012 #6 Yes, the "|" is a metacharacter and it has to be escaped like this: "\|". Upvote 0
paolofi Member Licensed User Longtime User Dec 3, 2012 #7 NJDude said: Yes, the "|" is a metacharacter and it has to be escaped like this: "\|". Click to expand... Many thanks NJDude now it works: Code: Copy strSplit=Regex.Split("\|",Value ) Upvote 0
NJDude said: Yes, the "|" is a metacharacter and it has to be escaped like this: "\|". Click to expand... Many thanks NJDude now it works: Code: Copy strSplit=Regex.Split("\|",Value )