Group String in Array and Json

@Pablo_Sanchez
With the help of Regex we can split the string


refering to the groups (we will trim later)
grafik

For regex learning have a look here:

With following flow we can achieve the result:
grafik

grafik

The main idea is about:

  • use regex to as mentioned above
    Regex.Matches(strText, strPattern, RegexOptions.IgnoreCase)

  • group the matches and create JProperties, return all as an array

(From m In myMatches.Cast(Of Match).toList
Group m By k=m.Groups(1).Value.Trim Into grp = Group
Let arrVal = grp.Select(Function (a) a.Groups(2).Value.Trim).toArray
Let ja = JArray.FromObject(arrVal)
Select p = New JProperty(k, ja)).toarray
  • Create the JObject from the returned JProperty Array
    new JObject(arrProps)

We had used LINQ:

But can also decompose the LINQ part to essential activities

Find starter help here:
ppr_RegexBox_PabloSanchez.xaml (7.0 KB)

2 Likes