using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^>
(?P<header>
[^\n()]*
(?:\((?P<name>[^\n()]+)\))?
[^()\n]*
)
[\n\r]
(?P<content>[\s\S]+?)(?=^>|\Z)";
string input = @">XM_024446048.1 PREDICTED: Homo sapiens mannosidase alpha class 2A member 1 (MAN2A1), transcript variant X2, mRNA
CAGCCCCC
TGAGCGAC
TCCCTAATGTG
ACAGTAAAGAA
>NM_001308028.1 Homo sapiens FER tyrosine kinase (FER), transcript variant 2, mRNA
CAGCCC
CCGTGACGC
GGGGTGGTGACT
GGCTC
GGTGGT
GTGAC
>NM_0013082323028.1 H STZ mRSN1A
CAGCCC
CCGTGACGC
GGG
GTGGTGA
CTGGCTCCGGAGT
CTGAGGGGTTCGG";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace;
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