using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(benz\s+[[:alpha:]]+)\d\w*";
string substitution = @"\1";
string input = @"2010 mercedes-benz sl500r
2010 mercedes-benz e550
2010 mercedes-benz glk350
2010 mercedes-benz c300w
2010 mercedes-benz 300
(""2010 mercedes-benz sl"",
""2020 mercedes-benz e"",
""2017 mercedes-benz glk"",
""2013 mercedes-benz c"",
""2014 mercedes-benz 300"")";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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