fifiddu70 Well-Known Member Licensed User Longtime User May 20, 2017 #1 hello, i have one spinner with this elemet: 1:Bicchiere di birra - Euro 5.50 i need to insert in other edittext: 1 Bicchiere di birra without Price. one help?
hello, i have one spinner with this elemet: 1:Bicchiere di birra - Euro 5.50 i need to insert in other edittext: 1 Bicchiere di birra without Price. one help?
klaus Expert Licensed User Longtime User May 20, 2017 #2 You can use both: Regex: Code: Dim str = "1:Bicchiere di birra - Euro 5.50" As String Dim str1() As String str1 = Regex.Split(" - ", str) str1(0) = str1(0).Replace(":", " ") SubString2: Code: Dim str = "1:Bicchiere di birra - Euro 5.50" As String Dim str2 As String str2 = str.SubString2(0, str.IndexOf(" - ")) str2 = str2 .Replace(":", " ") If you need to have also the price separated, Regex is easier. Upvote 0
You can use both: Regex: Code: Dim str = "1:Bicchiere di birra - Euro 5.50" As String Dim str1() As String str1 = Regex.Split(" - ", str) str1(0) = str1(0).Replace(":", " ") SubString2: Code: Dim str = "1:Bicchiere di birra - Euro 5.50" As String Dim str2 As String str2 = str.SubString2(0, str.IndexOf(" - ")) str2 = str2 .Replace(":", " ") If you need to have also the price separated, Regex is easier.
udg Expert Licensed User Longtime User May 20, 2017 #3 To take in account eventual dash separated names like "lemon-mint" I'd search from the end backward. Try with "1: Fresh lemon-mint soda - Eur 7.60" to see what I mean. udg Upvote 0
To take in account eventual dash separated names like "lemon-mint" I'd search from the end backward. Try with "1: Fresh lemon-mint soda - Eur 7.60" to see what I mean. udg
fifiddu70 Well-Known Member Licensed User Longtime User May 20, 2017 #4 Thanks Friends, i try your code, work fine, but i replace ( " - " ) with ( " Euro " ) because i have elemtns with example: 1: Fresh lemon-mint soda - Eur 7.60 good work Klaus and Good work Udg, very thanks all. Upvote 0
Thanks Friends, i try your code, work fine, but i replace ( " - " ) with ( " Euro " ) because i have elemtns with example: 1: Fresh lemon-mint soda - Eur 7.60 good work Klaus and Good work Udg, very thanks all.
klaus Expert Licensed User Longtime User May 20, 2017 #5 In my code, "1: Fresh lemon-mint soda - Eur 7.60" works OK, because I use the empty characters " - " before the "-" character. But this would be wrong: "1: Fresh lemon - mint soda - Eur 7.60" But splitting with " - Euro " is better. You might use " - Euro " to eliminate "-". Upvote 0
In my code, "1: Fresh lemon-mint soda - Eur 7.60" works OK, because I use the empty characters " - " before the "-" character. But this would be wrong: "1: Fresh lemon - mint soda - Eur 7.60" But splitting with " - Euro " is better. You might use " - Euro " to eliminate "-".
fifiddu70 Well-Known Member Licensed User Longtime User May 20, 2017 #6 yes Klaus your last post with this code is very good, i change in your code, thanks. Upvote 0