Skip to content

Instantly share code, notes, and snippets.

@mashiro
Created January 7, 2010 19:32
Show Gist options
  • Select an option

  • Save mashiro/271490 to your computer and use it in GitHub Desktop.

Select an option

Save mashiro/271490 to your computer and use it in GitHub Desktop.
string text = "source text";
Match match = null;
List<Func<bool>> funcs = new List<Func<bool>>() {
() => { match = Regex.Match(text, "pattern1"); return match.Success; },
() => { match = Regex.Match(text, "pattern2"); return match.Success; },
() => { match = Regex.Match(text, "pattern3"); return match.Success; },
() => { match = Regex.Match(text, "pattern4"); return match.Success; },
() => { match = null; return true; }
};
funcs.TakeWhile(f => !f()).ToList();
if (match == null) throw new Exception("no match");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment