using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?:\d\h+|[\d.]*[A-Z][A-Z\d.]*\h+)*[A-Z]{3,}";
string input = @"ID.4 ESTATE 109kW City Pure 52kWh 5dr Auto
XC40 DIESEL ESTATE 2.0 D4 [190] Inscription Pro 5dr AWD Gea+
RAPID DIESEL HATCHBACK 1.6 TDI CR Elegance 5dr
MODEL 3 120kW LONG RANGE AWD
V40 DIESEL HATCHBACK D2 [120] Momentum 5dr Geartronic
V60 DIESEL SPORTSWAGON 2.0 D4 [190] R DESIGN Plus 5dr Auto
X3 ESTATE xDrive M40i 5dr Auto
C CLASS DIESEL SALOON C250 BlueTEC SE 4dr Auto
A CLASS DIESEL HATCHBACK A180d Sport Executive 5dr Auto
2 SERIES COUPE 218i Sport 2dr [Nav] Step Auto
HILUX SPECIAL EDITIONS Invincible X Ltd Ed D/Cab P/Up 2.4 D+
C3 PICASSO 1.6 BlueHDi Platinum 5dr
C3 HATCHBACK 1.2 PureTech 82 Flair 5dr
XC40 DIESEL ESTATE XC40
1";
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