using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"operator\D+(\d+)";
string input = @"I have following string dfed operator 11 - 145. I am trying to match string operator 11 and inside this matched string, i am trying to match string 11. Currently I successfully matched operator 11 with regex ((O|o)perator(i|I)?\s*)\d+(?=\s*(-|_)\s*\d+). As I am in javascript, I can not use lookbehinds.
Is my approach correct? Is there any way to accomplish this in regex? How can i match string 11 inside previously matched string operator 11?";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
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