Created
October 16, 2014 07:13
-
-
Save JohanLarsson/c295f32f4e3e6b7eb355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var symbols = UnitBase.AllUnitsStatic.Select(x => x.Symbol).ToArray(); | |
var symbolsPattern = string.Join("|", new[] { "1" }.Concat(symbols)); | |
var pattern = string.Format(@"(?<Unit> | |
(?<Symbol>({0})) | |
( | |
(?:\^) | |
(?<Power>[+-]?\d+) | |
)? | |
| | |
(?<Op>[⋅\*\/]) | |
)", symbolsPattern); | |
var matches = Regex.Matches(s, pattern, RegexOptions.IgnorePatternWhitespace); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment