今天學習VBscrpt下的正則表達式時,有段代碼執行老是提示語句爲結束,請過請教他人,發現原來是我把多個語句寫到一行造成的。
多個語句本身是可以的,但有個規則,即需要在語句之間加":",如For Each objMatch In colMatches:sMsg = sMsg & "Blank line found at position" & objMatch.FirstIndex & "of the string.":Next。但是爲了便於代碼閱讀,一般不這樣寫。
另外,有些語句比較長時,需要多行,此時需要"_"來連接,如:sMsg = sMsg & "Blank line found at position" & _
objMatch.FirstIndex & "of the string."
這些都是很基礎的東西,但越是細微的東西,越容易被忽略,所以記錄下來,以免忘記