Split a string with x

Hi team,

I have a string “139204502930259406835392043409548409409586392049777396029396849302”

Now i want to split this string with every 5 characters.
The expected output is :

13920
45029
30259
40683
.
.
.
.
etc

Please suggest me if you have something.

Regards,
Sateesh.

Hi @sateesh.thandra

Try these :

  1. Open the Invoke Code activity.

  2. Set up your inputString variable with the value - assign this to string variable with in direction to use inside code

  3. “139204502930259406835392043409548409409586392049777396029396849302”.

  4. Create a chunks variable as a List(Of String) to store the split strings.- this will be assigb the direct out in your invoke code

  5. Use the following code in the Invoke Code activity

Dim inputString As string
Dim chunks As New List(Of String)
For i As Integer = 0 To inputString.Length - 1 Step 5

Dim chunk As String = inputString.Substring(i, Math.Min(5, inputString.Length - i))

chunks.Add(chunk)

Next

to access chunks outside the Invoke Code activity, make sure to pass it as an Out Argument in the activity’s properties.

use regex and split it

System.Text.RegularExpressions.Regex.Matches(“139204502930259406835392043409548409409586392049777396029396849302”, “.{1,5}”).Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Value).ToList()

assign the above expression into list of strings

Hi @sateesh.thandra

Fallow the steps below. If I helped you, please maket it as solved.
Here is the code.
Main.xaml (5.2 KB)

Thanks this worked for me.

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