Dividing the string

Hi All

I want to add all the values in the below String in different Variables For a

single Input String

  1. 9182
  2. Nonhlanhla
  3. someone@gmail.com
  4. 11409
    something
    Kagiso 6
    Gauteng
    1754
  5. Capitec,15176, sav
  6. 29
  7. Bambisana,Admi

I want the Variable value as

Var1 = “9182”
Var2 = “Nonhlanhla”
Var3 = “someone@gmail.com
Var4 =" 11409
something
Kagiso 6
Gauteng
1754"

Var5 = Capitec,15176, sav
.
.

Can some one help me out

@Kethavath_Shankar_Naik

is the string is separated by new line if so use this

arr_strnames=outputstr.Split(vblf,StringSplitOptions.RemoveEmptyEntries).toarray

you can call each value by index and assign to a variable

strname=outputstr.Split(vblf,StringSplitOptions.RemoveEmptyEntries)(0)

int_Number=outputstr.Split(vblf,StringSplitOptions.RemoveEmptyEntries)(1)

Hi @Kethavath_Shankar_Naik ,

Maybe we could try with a regex operation where we can store each key(Starting Numbering) with value as Dictionary.

Using the below Regex :

(?<=\d+\.)[\S\s]+?(?=\d+\.)

Steps to Perform :

  1. Add a “0.” at the End of the Input String so that we will be able to anchor and get the last item as well with the regex developed.
    image

  2. Use Find Matching Patterns activity with the regex provided above and get the matched collection.

  3. Converting the matched data to a Dictionary variable so that we can access the each value using the Line Number as the key. Below is the Expression used :

dictVariables = mc.Cast(Of Match).ToDictionary(Function(x)(mc.ToList.IndexOf(x)+1).ToString,Function(y)y.Value.Trim)

Here, dictVariables is of Type Dictionary(Of String,String) and mc is the Output of Find Matching Patterns activity.

Implementation :

Debug :

Let us know if this works for your case and if not, let us know why.

Do we need any Packages to download Can you please let me know

@Kethavath_Shankar_Naik ,

No, We would not need any external packages. The Find Matching Patterns activity could also be Matches activity for your version of Studio.

The Dictionary Variable the values will Vary Every Time
so i need the values in a dynamic Way

@Kethavath_Shankar_Naik ,

I believe the solution suggested is dynamic, Did it not work for some input data ? If so, could you provide us that data ?

If you are getting string in below format

  1. 9182
  2. Nonhlanhla
  3. someone@gmail.com
  4. 11409
    something
    Kagiso 6
    Gauteng
    1754
  5. Capitec,15176, sav
  6. 29
  7. Bambisana,Admi

You can split string with new line
and assign activity assign string to your variable using index ),1 etc

Regards,
Namrata

1 Like


can you suggest a solution here i am unable to fetch Value

@Kethavath_Shankar_Naik ,

As provided in the Debugging Panel, I have used a String, and not a Integer value for the Dictionary key, so give a try with :

DictVar("2").ToString
1 Like

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