using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"<(\S+)>\s*<(\S+)>\s*(?:""(.+)""|<(\S+)>).*.";
string input = @"# started 2015-11-29T18:23:17Z
<http://dbpedia.org/resource/Bobcat_Company> <http://dbpedia.org/property/type> <http://dbpedia.org/resource/Subsidiary> .
<http://dbpedia.org/resource/Bobcat_Company> <http://dbpedia.org/property/website> <http://www.bobcat.com> .
<http://dbpedia.org/resource/Albedo> <http://dbpedia.org/property/colwidth> ""30""^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://dbpedia.org/resource/Anarchism> <http://dbpedia.org/property/voy> ""no""@en .
<http://dbpedia.org/resource/Anarchism> <http://dbpedia.org/property/n> ""no""@en .
<http://dbpedia.org/resource/Anarchism> <http://dbpedia.org/property/v> ""no""@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/keyPeople> ""Kevin Knight""@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/keyPeople> ""Keith Knight""@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/numEmployees> ""4400""^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/industry> ""motor transportation-trucking""@en .
<http://dbpedia.org/resource/Knight_Transportation> <http://dbpedia.org/property/products> ""truckload shipping""@en .
";
Match m = Regex.Match(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