Skip to content

Instantly share code, notes, and snippets.

@edqwerty1
Created June 7, 2019 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edqwerty1/3daaf8afdb7c211615bc3a6ccada96f8 to your computer and use it in GitHub Desktop.
Save edqwerty1/3daaf8afdb7c211615bc3a6ccada96f8 to your computer and use it in GitHub Desktop.
var ids = @"1,2
3
asf
4 5";
Regex rx = new Regex(@"(\d+)",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
MatchCollection matches = rx.Matches(ids);
var listIds = new List<int>();
foreach (Match match in matches)
{
listIds.Add(Convert.ToInt32(match.Value));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment