using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?i)(\bmarche\s(?:\d{5})?\-?(?:\d{3,5})|(?:\d{5})\-?(?:\d{4})?\smarche\b|[,]marche[\.,]|marche$)";
string input = @"NOT MATCH
Diabetologist,5,rue du marche,93160 Noisy le Grand,France.
Diabetologist,5,rue du lemarche,93160 Noisy le Grand,France.
Department of sea science,University Polytechnic of Marche,via Brecce Bianche,60100 Ancona,Italy.
ALL MATCH
Department of sea science,University Polytechnic of ,Marche,via Brecce Bianche,60100 Ancona,Italy.
Department of sea science,University Polytechnic of ,Marche 12345-1234,via Brecce Bianche,60100
Department of sea science,University Polytechnic of ,Marche
Department of sea science,University Polytechnic of ,Marche.
Department of sea science,University Polytechnic of ,Marche 12345
Department of sea science,University Polytechnic of ,Marche 12345.
Department of sea science,University Polytechnic of ,12345-1234 Marche.
Department of sea science,University Polytechnic of ,12345 Marche.
Department of sea science,University Polytechnic of ,Marche 12345,italy";
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