Skip to content

Instantly share code, notes, and snippets.

@demaderios
Last active May 21, 2020 19:13
Show Gist options
  • Save demaderios/8d02e2ad5660909ee50e380e19fb1c15 to your computer and use it in GitHub Desktop.
Save demaderios/8d02e2ad5660909ee50e380e19fb1c15 to your computer and use it in GitHub Desktop.
C# regular expression extractor
public static List<string> RegularExpressionExtractor(string input, string regexpattern)
{
var regexPatternToMatch = new Regex(regexpattern);
var listOfResults = regexPatternToMatch.Matches(input)
.Cast<Match>()
.Select(m => m.Value)
.ToList();
return listOfResults;
}
@demaderios
Copy link
Author

I had a need to run some strings through a parser to get specific sections of the string into a list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment