Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danmoseley/383b64ca94e1a320ff31ec68f23aaaea to your computer and use it in GitHub Desktop.
Save danmoseley/383b64ca94e1a320ff31ec68f23aaaea to your computer and use it in GitHub Desktop.
using System;
using System.Text.RegularExpressions;
Regex re = new Regex(@"\Gbar", RegexOptions.Compiled);
string fooBarString = @" bar";
var match1 = re.Match(fooBarString, 1);
Console.WriteLine(String.Format("Match 1 sucess: {1} {0}", match1.Success, match1.Index));
var match2 = re.Match(fooBarString, 1, fooBarString.Length-1);
Console.WriteLine(String.Format("Match 2 sucess: {1} {0}", match1.Success, match2.Index));
var match3 = re.Match(fooBarString.Substring(1, fooBarString.Length-1));
Console.WriteLine(String.Format("Match 2 sucess: {1} {0}", match3.Success, match3.Index))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment