Last active
December 25, 2015 21:59
-
-
Save noahm/7046231 to your computer and use it in GitHub Desktop.
for BOOEAN!
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
using System; | |
using System.Text.RegularExpressions; | |
class Program | |
{ | |
static void Main() | |
{ | |
// Input string. | |
const string example = "Name:\r\n\r\nEmail: [email protected]\r\n\r\nPhone: 333-343-0909\r\n\r\n"; | |
// Get a collection of matches with the Multiline option. | |
//MatchCollection matches = Regex.Matches(example, "^(.+)$", RegexOptions.Multiline); | |
MatchCollection matches = Regex.Matches(example, "^Name:([^\\n]*)$", RegexOptions.Multiline); | |
foreach (Match match in matches) | |
{ | |
// Loop through captures. | |
foreach (Capture capture in match.Captures) | |
{ | |
// Display them. | |
Console.WriteLine("--" + capture.Value); | |
} | |
} | |
} | |
} |
Updated to something that works, but will capture the leading whitespace in front of a name. Should be stripped out later.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like your capturing group should be something like
(\S[^\r\n]*$)
-- ensure that there's a non-whitespace character, and then continue to match characters that aren't the known terminators.