Skip to content

Instantly share code, notes, and snippets.

@ryancole
Created March 10, 2015 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryancole/29748985c431067cd1ba to your computer and use it in GitHub Desktop.
Save ryancole/29748985c431067cd1ba to your computer and use it in GitHub Desktop.
RegExWoo
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