Use regex?

Hi @Stef_99
Check below:

For Case 1 (AAK-20250314-154055-Trik-4_02SAA):

  • For Output 1: output1 = System.Text.RegularExpressions.Regex.Match(inputString, "^([A-Za-z0-9-]+-[A-Za-z0-9-]+-[A-Za-z0-9-]+-[A-Za-z0-9-]+-[0-9]+)").Groups(1).Value
  • For Output 2: output2 = System.Text.RegularExpressions.Regex.Match(inputString, "([A-Za-z0-9]+-[A-Za-z0-9]+)-([A-Za-z0-9]+$)").Groups(1).Value + "-" + System.Text.RegularExpressions.Regex.Match(inputString, "([A-Za-z0-9]+-[A-Za-z0-9]+)-([A-Za-z0-9]+$)").Groups(2).Value
  • For Output 3: output3 = System.Text.RegularExpressions.Regex.Match(inputString, "([A-Za-z0-9]+$)").Groups(1).Value

For Case 2 (AAK-20250364-153865-Trik-10_03ADF):

  • For Output 1: output1_2 = System.Text.RegularExpressions.Regex.Match(inputString2, "^([A-Za-z0-9-]+-[A-Za-z0-9-]+-[A-Za-z0-9-]+-[A-Za-z0-9-]+-[0-9]+)").Groups(1).Value
  • For Output 2: output2_2 = System.Text.RegularExpressions.Regex.Match(inputString2, "([A-Za-z0-9]+-[A-Za-z0-9]+)-([A-Za-z0-9]+$)").Groups(1).Value + "-" + System.Text.RegularExpressions.Regex.Match(inputString2, "([A-Za-z0-9]+-[A-Za-z0-9]+)-([A-Za-z0-9]+$)").Groups(2).Value
  • For Output 3: output3_2 = System.Text.RegularExpressions.Regex.Match(inputString2, "([A-Za-z0-9]+$)").Groups(1).Value

Please mark as a solution , if you found Helpful.
Thanks. Happy Automation

1 Like