using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using org.mariuszgromada.math.mxparser;
public readonly string Name;
public readonly string Value;
public Token(string name, string value)
public static void Main()
@"(?<variable>[a-zA-Z_$][a-zA-Z0-9_$]*)|" +
Regex regexPattern = new Regex(pattern);
MatchCollection matches = regexPattern.Matches("365 + 6 * Count");
var tokenList = new List<Token>();
foreach (Match match in matches)
foreach (Group group in match.Groups)
string matchValue = group.Value;
bool success = group.Success;
string groupName = regexPattern.GroupNameFromNumber(i);
tokenList.Add(new Token(groupName , matchValue));
foreach(var t in tokenList) {
Console.WriteLine(t.Value);