How to regix for extract value

Hello.

I have value

  • AAK-20250314-154055-Trik-4-Import Inbound_02SAA
    expect 2 output
  1. AAK-20250314-154055-Trik-4
  2. 02SAA-Trik-4
  • AAK-20250364-153865-Trik-10-Import Inbound_03ADF
    expect 2 output
  1. AAK-20250364-153865-Trik-10
  2. 03ADF-Trik-10

Plase guide me for solve it.

Thank you

Hi @Stef_99
Could you give me a breakdown on the input? what are the possible cases (what text remains fixed, and what changes?

Hi @Stef_99

Use this regex in UiPath:

  1. For first output:

    ^(AAK-\d{8}-\d{6}-Trik-\d+)
    
    • Use System.Text.RegularExpressions.Regex.Match(input, pattern).Value
  2. For second output:

    (\d{2}[A-Z]{3})-Trik-\d+
    
    • Use System.Text.RegularExpressions.Regex.Match(input, pattern).Value

Let me know if you need adjustment

Hi @Stef_99

Here is one approach:

1. For the first Output:

  • The Assign Statement::
output1 = System.Text.RegularExpressions.Regex.Match(inputString, "\S{3}-\d{8}-\d{6}-Trik-\d+").Value
  • The regex pattern used is: "\S{3}-\d{8}-\d{6}-Trik-\d+"

1. For the second Output:

  • The Assign Statement::
output2 = System.Text.RegularExpressions.Regex.Match(inputString, "(?<=_).*").Value +"-" + System.Text.RegularExpressions.Regex.Match(inputString, "Trik-\d+").Value
  • The regex patterns used are: "(?<=_).*" and "Trik-\d+"

The Results:

If this solves your issue, Do mark it as a solution.
Happy Automation :star_struck:

@V_Roboto_V @prashant1603765 last question

If input AAK-20250314-154055-Trik-4-Import Inbound_02SAA

I expect output 02SAA

Please guide me for solve it.

Thank you

1 Like

By removing the second half of the Assign statement of output2, you can get output3

output3 = System.Text.RegularExpressions.Regex.Match(inputString, "(?<=_).*").Value

Output:

1 Like

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