using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(^disk\W+\[)?('file:[^']+'(,)?)?('phy:[^']+'(,)?)?(])?";
string substitution = @"";
string input = @"disk = ['file:/OVS/Repositories/0004fb0000030000c83b5c9f7ae78c70/VirtualDisks/0004fb00001200009ddb6b8cbb9a3ad2.img,xvda,w', 'phy:/dev/mapper/3624a9370ab906bd01c3f4e00000112a2,xvdb,w', 'phy:/dev/mapper/3624a9370ab906bd01c3f4e0000011061,xvdc,w', 'phy:/dev/mapper/3624a9370ab906bd01c3f4e00000110a0,xvdd,w', 'file:/dev/mapper/3624a9370ab906bd01c3f4e000001129a,xvde,w', 'phy:/dev/mapper/3624a9370ab906bd01c3f4e000001132c,xvdf,w']
";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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