using System;
using System.Text ;
using System.Text .RegularExpressions ;
namespace Test
{
class Test
{
static void Main( )
{
string s0 = @"Public Class Class1
Public Sub New()
''asdasdas
Dim a As String = " "" " REM asdasd
''' asd ad asd
End Sub
Public Sub New(ByVal strg As String)
Dim a As String = " "Name='Soham'" "
Dim b As Boolean = True ' a " "line ending" " comment
End Sub
End Class" ;
string r1 = @"(?m)^[ \t ]*(?:(?:REM|')[^\r \n ]*)?[\r \n ]+" ;
string r2 = @"(?mn)^(?<line>[^\r \n " "R']*((" "[^" "]*" "|(?!REM)R)[^\r \n " "R']*)*)(REM|')[^\r \n ]*" ;
Console.WriteLine ( s0) ;
string s1 = Regex.Replace ( s0, r1, String.Empty ) ;
s1 = Regex.Replace ( s1, r2, @"${line}" ) ;
Console.WriteLine ( "\n \n {0}" , s1) ;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zOwoKCm5hbWVzcGFjZSBUZXN0CnsKICBjbGFzcyBUZXN0CiAgewogICAgc3RhdGljIHZvaWQgTWFpbigpCiAgICB7CiAgICAgIHN0cmluZyBzMCA9IEAiUHVibGljIENsYXNzIENsYXNzMQogICAgUHVibGljIFN1YiBOZXcoKQogICAgICAgICcnYXNkYXNkYXMKICAgICAgICBEaW0gYSBBcyBTdHJpbmcgPSAiIiIiIFJFTSBhc2Rhc2QKICAgICAgICAnJycgYXNkIGFkIGFzZAogICAgRW5kIFN1YgoKCiAgICBQdWJsaWMgU3ViIE5ldyhCeVZhbCBzdHJnIEFzIFN0cmluZykKCiAgICAgICAgRGltIGEgQXMgU3RyaW5nID0gIiJOYW1lPSdTb2hhbSciIgoKICAgICAgICBEaW0gYiBBcyBCb29sZWFuID0gVHJ1ZSAnIGEgIiJsaW5lIGVuZGluZyIiIGNvbW1lbnQKCiAgICBFbmQgU3ViCgoKRW5kIENsYXNzIjsKICAgICAgc3RyaW5nIHIxID0g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