-4

I'm trying to combine two patterns into 1:

string pattern_1 = @"smoke-test-app-[0-9A-Fa-f\-]{36}";
string pattern_2 = @"SMOKES-[0-9]-APP-[0-9A-Fa-f\-]{16}";

Test string for pattern_1: smoke-test-app-f47980d7-b3e5-49eb-99b6-d7413e16a0bc

Test string for pattern_2: SMOKES-2-APP-a9a8f59dd3c74046

Sam
  • 471
  • 7
  • 24

1 Answers1

2

One key things to understand here is the possibility to use insensitive case, since you have the same word in both uppercase and lowercase. As for the rest, it's basic OR operaiton.

/smoke(s?)-(test|\d{1})-app-([0-9A-Fa-f\-]{36}|[0-9A-Fa-f\-]{16})/gmi

Note that the i flag is important here.

I've created a regex101 if you wish to test more cases

P.S.
I did this out of pure love for regexes, but we would have appreciated if you tried yourself first.

Nicolas
  • 8,077
  • 4
  • 21
  • 51