Cosider please the following:

string s1 = PREabcdPOST;
string s2 = PREabPOST;


string[] srar = ["ab", "abcd"];
// this can not be constructed with a particular order

foreach(sr; srar)
{

  auto r = regex(sr; "g");
  auto m = matchFirst(s1, r);
  break;
  // this one matches ab
  // but I want this to match abcd
  // and for s2 I want to match ab

}

obviously there are ways like counting the match length, and then using the maximum length, instead of breaking as soon as a match is found.

Are there any other better ways?

Reply via email to