using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"name=\""(?P<name>\w+)\""\>[\w\<\/\.\>\d:]+documentation\>(?P<desc>[\w\s\.]+)\<\/";
string input = @"<xs:element name=""ProductDescription""><xs:annotation><xs:documentation>Provides the description of the product</xs:documentation></xs:annotation><xs:complexType><xs:sequence><xs:element name=""ProductName""><xs:annotation><xs:documentation>Provides a name for the product. (see list)</xs:documentation></xs:annotation><xs:simpleType><xs:restriction base=""xs:token""><xs:enumeration value=""Barbie Doll""/><xs:enumeration value=""Ken Doll""/></xs:restriction></xs:simpleType></xs:element><xs:element name=""ProductSize""><xs:annotation><xs:documentation>Describes the size of the product. (see list)</xs:documentation></xs:annotation><xs:simpleType><xs:restriction base=""xs:token""><xs:enumeration value=""Small""/><xs:enumeration value=""Medium""/><xs:enumeration value=""Large""/><xs:enumeration value=""Dayum""/></xs:restriction></xs:simpleType></xs:element></xs:sequence></xs:complexType></xs:element>";
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