using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?mis)^\bgeneral( #[0-9])?(.*?)^\s*$";
string input = @"General
Complete name : C:\Projects\Foray\MediaEngine\SampleMedia\flv\small.flv
Format : Flash Video
File size : 296 KiB
Duration : 5s 560ms
Overall bit rate mode : Variable
Overall bit rate : 436 Kbps
Writing application : Lavf52.103.0
Video
Format : Sorenson Spark
Codec ID : 2
Duration : 5s 560ms
Bit rate : 781 Kbps
Width : 320 pixels
Height : 240 pixels
Display aspect ratio : 4:3
Frame rate mode : Constant
Frame rate : 25.000 fps
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.407
Stream size : 530 KiB
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 2
Codec ID/Hint : MP3
Duration : 5s 512ms
Bit rate mode : Variable
Bit rate : 63.8 Kbps
Channel(s) : 1 channel
Sampling rate : 44.1 KHz
Compression mode : Lossy
Stream size : 42.9 KiB (14%)
";
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