Regex Expression For String

Hi Everyone,
Can anyone suggest a method to manipulate the below string values? The string contains a dynamic value.

Example Input:
stringInput = 21841/22OA00063
stringInput = 1931-22OA00239
stringInput = 22CO00202 22CO00202
stringInput = 22OA00008-1876/21
stringInput = 21CO00820/2035/12

Desired Output:
22OA00063
22OA00239
22CO00202
22OA00008
21CO00820

The input string would always contain “OA” or “CO”, two digits before “OA” or “CA” and five digits after “OA” or “CO”.

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(stringInput,"\d{2}[A-Z]{2}\d{5}").Value

Regards,

1 Like

a simple one matching in one case too much, but can he handled by taking the first match or using the regex.Match method:

grafik
\w{7,}

1 Like

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