Splitting String at multiple words

Hi @Pathler ,

As @Shikhar_Tandon was saying, you could use the System.Text.RegularExpressions.Regex.Split method in order to get your output, let me show you an example:

image

Value:

System.Text.RegularExpressions.Regex.Split(var_InitText,"(\d{3})").ToList

This will split the string every time 3 numbers are found in a row (Regex = \d{3}, and will include them on the list if you want (because of the “()” grouping the expression, creating this output:

image

  • to match exactly your output, you’ll need to join some of the values to get it as you please.

If you don’t want the numbers, remove the () from the expression:

  • Regex - no numbers included: "\d{3}"

image

Hope this is what you need!

3 Likes