fudi5
(Piotr Fudala)
April 3, 2018, 11:54am
1
Hi,
Can anyone tell me how to use split in case where i know where to start and cut to the end of text.
For example. Im startm on word “Community” and i dont know how long can it be whole phrase but i want to finish on the end of whole string.
Regards,
@fudi5
1 Like
arivu96
(Arivazhagan A)
April 3, 2018, 12:14pm
2
HI @fudi5 ,
my understanding was from the string value you need last word right??
If yes
strValue.Split(" "c).Last.ToString()
Regards,
Arivu
1 Like
fudi5
(Piotr Fudala)
April 3, 2018, 12:22pm
3
Hi @arivu96 ,
Not last word. I start split form"Community" and it finish on the end of whole string… there should be word1, word2, word3, word4 and last is word5 so split should finished after word5. There is nothing after word5.
I thing i need something like that: “Split(expression[,delimiter[,count]])”. Where count will be -1
Regards,
@fudi5
arivu96
(Arivazhagan A)
April 3, 2018, 12:51pm
4
HI @fudi5 ,
Do your string will be like this
"word1, word2, word3, word4, word5 "
so you want “word5” as output right???
strValue.Split(","c).Last.ToString()
Regards,
Arivu
fudi5
(Piotr Fudala)
April 3, 2018, 12:58pm
5
hi @arivu96 ,
Starting string: “word0 word1 word2 word3 word4 word5”
Start split from word0
And my output in this case: “word1 word2 word3 word4 word5”
Regards
@fudi5
arivu96
(Arivazhagan A)
April 3, 2018, 1:35pm
6
Hi @fudi5 ,
fudi5:
Start split from word0
Instead of split you can use replace function.
strValue.Replace("word0 ","")
Regards,
Arivu
fudi5
(Piotr Fudala)
April 3, 2018, 2:25pm
7
Hi @arivu96 ,
I dont catch your advice. How can i use replace instead of split if i need part of string… i start split from word0 but this is not a first word in string… so thank but i found solution.
Solution is use split(strValue,“word0”,-1)
Regards
@fudi5
tmays
(Troy)
April 4, 2018, 3:13am
8
Hi @fudi5
Using Substring and IndexOf is probably a better bet than split in your case. (Unless you have to use split for some reason.)
StrValue.Substring(StrValue.IndexOf("Community"))
Like this:
Community.xaml (9.3 KB)
Regards
Troy
fudi5
(Piotr Fudala)
April 4, 2018, 6:12am
9
hi @tmays ,
Yes there is a reason. This solution must be prepared for dynamic text so using indexOf in this case close this solution to one case…
Regards
@fudi5