using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"site[\s\S]{0,100}\/a>";
string input = @"<body>
<!-- Websites navigation menu -->
<ul class=""navbar"">
<li><a href=""index.html"">Home page</a>
<li><a href=""musings.html"">Musings</a>
In the following code, what is the regex (within Sublime's search) for finding ""site"" (seen within ""Websites"") and /a> (seen within ) only when there are between 0 and 50 characters of any type in between those two strings? I'd like to be able to perform searches like this on a regular basis, just changing out the two keywords and a distance, thanks.";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx