using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!\S)-{2}\b[a-z][a-z\d]{2,}\b(-{1}[a-z\d]+)*(?!\S)";
string substitution = @"";
string input = @"--valid
--th1s-is-also-val1d
--match-this-option-as-well
--9this-is-invalid-because-of-the-leading-digit
--this--is--invalid--because--of--word--wrapping--by--multiple--hyphens
--this-should-also-fail-because-of-the-trailing-hyphen-
";
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