Split the string in two output

Hi all,

I have a input as “9914, 8871,1244,4566”

I want two output as
Stroutp1 as 9914
Stroutp2 as 8871,1244,4566

Note. In input there may be n number of split(,) i want one value in output1 and output2 as remaining value

Kindly help.

Thanks

Hi @vaish

inputString = "9914, 8871,1244,4566"
splitArray = inputString.Split(","c)
strOutp1 = splitArray(0).Trim()
strOutp2 = String.Join(",", splitArray.Skip(1).Select(Function(s) s.Trim()))

Output:

image

Regards,

@vaish

Assign inputStr = "9914, 8871,1244,4566"
 inputStr.Split(","c)(0).Trim()
 String.Join(",", inputStr.Split(","c).Skip(1).Select(Function(s) s.Trim()).ToArray())

1 Like

Hi @vaish

you can use regular expression to extract the first value and the remaining values from the input string

Stroutp1 = System.Text.RegularExpressions.Regex.Match(inputString, “^\d+”).Value

Stroutp2=System.Text.RegularExpressions.Regex.Replace(inputString, “^\d+,?”, “”)

image

image

Thanks & Regards ,
Sneha

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.