using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\|poke\|p([1,2])\|(.+?)(,|\|)";
string input = @"|poke|p1|Volcarona, M|
|poke|p1|Urshifu-*, F|
|poke|p1|Magnezone|
|poke|p1|Tangrowth, M|
|poke|p1|Corviknight, F|
|poke|p1|Hippowdon, F|
|poke|p2|Togekiss, M|
|poke|p2|Kommo-o, M|
|poke|p2|Jirachi|
|poke|p2|Mimikyu, F|
|poke|p2|Dragalge, F|
|poke|p1|Dragapult, F|
|poke|p1|Hatterene, F|
|poke|p1|Flygon, F|
|poke|p1|Inteleon, F|
|poke|p1|Obstagoon, F|
|poke|p1|Arcanine, F|
|poke|p2|Pincurchin, F|
|poke|p2|Magnezone|
|poke|p2|Hawlucha, F|
|poke|p2|Raichu-Alola, M|
|poke|p2|Ferrothorn, M|
|poke|p2|Magearna-Original|
|poke|p1|Slowbro, M|
|poke|p1|Tangrowth, F|
|poke|p1|Crawdaunt, F|
|poke|p1|Dragapult, M|
|poke|p1|Clefable, M|
|poke|p1|Excadrill, M|
|poke|p2|Togekiss, F|
|poke|p2|Starmie|
|poke|p2|Urshifu-*, M|
|poke|p2|Amoonguss, M|
|poke|p2|Cinderace, F|
|poke|p2|Jirachi|";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx