40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
Const CRLF = Chr(13) + Chr(10)
|
|
|
|
Function stripBlocks(text As String, first As String, last As String) As String
|
|
Dim As String temp = ""
|
|
For i As Integer = 1 To Len(text) - Len(first)
|
|
If Mid(text, i, Len(first)) = first Then
|
|
i += Len(first)
|
|
Do
|
|
If Mid(text, i, 2) = CRLF Then temp &= CRLF
|
|
i += 1
|
|
Loop Until (Mid(text, i, Len(last)) = last) Or (i = Len(text) - Len(last))
|
|
i += Len(last) -1
|
|
Else
|
|
temp &= Mid(text, i, 1)
|
|
End If
|
|
Next i
|
|
Return temp
|
|
End Function
|
|
|
|
Dim As String source
|
|
source = " /**" + CRLF + _
|
|
" * Some comments" + CRLF + _
|
|
" * longer comments here that we can parse." + CRLF + _
|
|
" *" + CRLF + _
|
|
" * Rahoo " + CRLF + _
|
|
" */" + CRLF + _
|
|
" function subroutine() {" + CRLF + _
|
|
" a = /* inline comment */ b + c ;" + CRLF + _
|
|
" }" + CRLF + _
|
|
" /*/ <-- tricky comments */" + CRLF + _
|
|
"" + CRLF + _
|
|
" /**" + CRLF + _
|
|
" * Another comment." + CRLF + _
|
|
" */" + CRLF + _
|
|
" function something() {" + CRLF + _
|
|
" }" + CRLF
|
|
|
|
Print stripBlocks(source, "/*", "*/")
|
|
Sleep
|