How to use regix?

Hello.
I have value = AAK-20250314-154055-Trik-4-02SAA

I want expect 3 output

  1. AAK-20250314-154055-Trik-4
  2. 02SAA-Trik-4
  3. 02SAA

Value = AAK-20250364-153865-Trik-10-03ADF
expect 3 output

  1. AAK-20250364-153865-Trik-10
  2. 03ADF-Trik-10
  3. 03ADF

Please guide me for solve it by use regex
Thankyou

Hi,

Can you try the following sample?

m =System.Text.RegularExpressions.Regex.Match(strData,"^([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)$")

Then

m.Groups(1).Value+"-"+m.Groups(2).Value+"-"+m.Groups(3).Value+"-"+m.Groups(4).Value+"-"+m.Groups(5).Value

m.Groups(6).Value+"-"+m.Groups(4).Value+"-"+m.Groups(5).Value

m.Groups(6).Value

Sample
Sample20250324-2.zip (2.7 KB)

Regards,

2 Likes

StringSplit.zip (156.1 KB)
The same can be achieved using string split() function as well.

Please find the code snippet.

1 Like

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