using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\/dev\/(sdf|xvd)[a-p][0-9]{0,1})\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\%\s+([^\n]*)$";
string input = @"/dev/xvda1 7.8G 1.1G 6.4G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 284M 12K 284M 1% /dev
tmpfs 59M 192K 59M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 295M 0 295M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvdf 20G 102M 19G 1% /mnt/data
";
RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline;
Match m = Regex.Match(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