Created
March 10, 2015 22:27
-
-
Save ryancole/29748985c431067cd1ba to your computer and use it in GitHub Desktop.
RegExWoo
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
using System; | |
using System.Text.RegularExpressions; | |
namespace RegExWoo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var text = "701 N.Y.S.2d 766, 123 N.Y.S.2d 256 (N.Y.City Civ.Ct. 1999), McEntee v Cappucci"; | |
var pattern = new Regex(@"\(.*?\)|(\d+) (\S+) (\d+\w)", RegexOptions.Compiled | RegexOptions.Multiline); | |
foreach (Match match in pattern.Matches(text)) | |
{ | |
if (match.Groups.Count == 4) | |
{ | |
var combined = match.Groups[1].Value.Trim() + | |
match.Groups[2].Value.Trim() + | |
match.Groups[3].Value.Trim(); | |
if (combined.Length > 0) | |
{ | |
Console.WriteLine(string.Join(" ", match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value)); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment