Last active
January 15, 2017 23:58
-
-
Save Porges/9ba3b7f94f2c14e20feb16c984406e5a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 input = "Example task section 1 section tomorrow section tagone tagtwo tagthree tagfour"; | |
| // regex altered slightly from question | |
| var r = new Regex(@"^([\w ]+) section (\d) section (\w+) section(?: (\w+))+$"); | |
| var g = r.Match(input).Groups; | |
| var output = $"{g[1]} !{g[2]} ^{g[3]} " + | |
| string.Join(" ", g[4].Captures.Cast<Capture>().Select(x => "#" + x)); | |
| // output: "Example task !1 ^tomorrow #tagone #tagtwo #tagthree #tagfour" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment