Split Codes in letters and digits

I’ve a spreadsheet with 8 columns and about 20 rows. One of the columns is “Code”. This has column has codes like “D20”, “T76”, “D54” etc. I want to split this code into two parts. One part will have the letter like ‘D’, “T’ and other part will have the digits like 54, 76 etc.
I’ve used Read Range, Assigned two variables - one each for letter and digits. I’m using System.Text.RegularExpressions.Regex.Matches(row(“code”),”[0-9]") in Studio but it does not work. How do I get “D” in var1, “54” in var 2 for each row? Easier way.


Can you try the following?

m = System.Text.RegularExpressions.Regex.Match(row("Code").ToString,"([A-Z]+)(\d+)")


m.Groups(1).Value returns D
m.Groups(2).Value returns 54

Note: m is System.Text.RegularExpressions.Match type.


1 Like

Thank you! @Yoichi
To try this out, I started with only one string. So here’s what I did:

  1. Defined a variable of type String and added a default string “D54”
  2. Used Assign Activity
    textvar = System.Text.RegularExpressions.Regex.Match(str1,"([A-Z]+)(\d+)")
  3. Used Write Line Activity
  4. Used Write Line Activity

Note - textvar is System.Text.RegularExpressions.Match type

When I run the code, the Output in blank. Any reason why should it be blank / empty ?

Hi @Prinal_C - Please check this…

1 Like

@prasath17 This worked. Thank you !

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