using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?!MsgBox\().*(*SKIP)(*F)|(?:(?:.{1,70}|.{71,140}|.{141,210}|.{211,280})|\G(?!^))\S+\K\h(?=.{25,}$)";
string substitution = @" "" _\n & """;
string input = @"'Some looooooong comment Lorem ipsum dolor sit amet, consectetur adipiscing
'elit. Ut a volutpat dolor. In risus odio, pharetra a arcu in, efficitur
'ornare lectus. Maecenas non aliquet leo. Praesent luctus blandit
'magna, et sagittis ex porta et.
MsgBox(""Some text in MsgBox. Donec vulputate eros ac nulla hendrerit auctor. In hac habitasse platea dictumst. Proin fermentum augue elit, eget consequat massa mattis et. Integer semper imperdiet diam sit amet malesuada."", 64, ""Title of MsgBox"")
'Another comment now with link to doc.
'https://example.com/?bs64=SWYgeW91IGFyZSBzbWFydCBlbm91Z2ggdG8gZGVjb2RlLCB5b3UgbXVzdCBkZWZpbml0ZWx5IHdhdGNoIHRoaXM6IGh0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9b0hnNVNKWVJIQTA=";
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