我正在编写一个 Lua 语言语法荧光笔,所以我需要处理注释。 该库需要一个正则表达式来输出需要着色的字符串。 它应该像这样工作:
输入:
test() --I'm a comment
输出:
--I'm a comment
还有
输入:
command .. "--help etc"
无输出
最佳答案
这应该适合你:
Dim m As Match = Regex.Match(testData1, "[^""]--.*")
If m.Success Then
Console.WriteLine(m.Value)
End If
关于正则表达式在 -- 如果没有用引号引起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22289771/