Split String and Retrieve a part of it

studio

#1

Hi,

I have a String and I want to split it and would like to retrieve a part of it.

OrgString = “Amit has two phones”
I need to print "two phones"Main.xaml (6.7 KB)

Please find attached my xaml file. Please guide me. Thanks in advance.


#2

Hi there @Deepak11,
If the String will always remain as:
“Amit has two phones”

You can do the following:
OrgString = OrgString.SubString(OrgString.IndexOf("has ") + 4), OrgString.Length - (OrgString.IndexOf("has ") + 4)

Alternatively, you can split it:
OrgString = OrgString.Split(Char.Parse(" "))(2) & " " & OrgString.Split(Char.Parse(" "))(3)

But, this will only work in this specific situation.

Thanks once again,
Josh


#3

@Deepak11 Check attached file meets your requirement

Previously you assigned string in this format str1 = “arr[2]” but right way is to assign is
str1 = arr(2).ToString

Main(1).xaml (7.3 KB)