is there any similar functionality like instr function in other language,
if UiPath has instr, then I can get a,b from a,b,c,d easily using
old_string=‘a,b,c,d’
new_string=substr(0,instr(old_string,‘,’,2)) —end position is where ‘,’ acurrs second time
new_string will be a,b
Probably you may like this:
str1=‘a,b,c,d’
strOutput = str1.Substring(0, str1.IndexOf(“,”,str1.IndexOf(“,”) + 1))
hi Vvaidya
thanks for your proposal, what if str1=‘a,b,c,d…(unknow length)…d,e,f,g,’ (e,g. ‘a,b,c,ddd,e,f,g’)
and I want strOutput to be previous part which is 'a,b,c,d…(unknow length)…d
so we should use str1.IndexOf(“,”) + n but we dont know what n is.
You may try below
str1 = “a,b,c,ddd,e,f,g”
split(str1,“,”).Take(4).ToArray ( result in array: a b c ddd)
split(str1,“,”).Skip(4).ToArray (result in array : e f g)
3,4 in above examples is basically comma occurances
hi vvaidya
thanks, it is a good solution, even shorter.
I have an alternative way also as below
list = str1.split(","c)
list.tolist.getrang(0,3)
1 Like