Created
May 29, 2022 05:20
-
-
Save danmoseley/383b64ca94e1a320ff31ec68f23aaaea to your computer and use it in GitHub Desktop.
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; | |
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