本文介绍了语法突出显示正确的正则表达式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用NSRegularExpression进行语法突出显示的正确正则表达式是什么?
What are the correct regular expressions using NSRegularExpression for syntax highlighting?
必须通过以下测试:
code // comment
code /* comment */ code
code "string" code
code // comment
code
code /* comment
comment */ code
code "string
code" string
code "string\
string" code
code // comment "comment"
code /* comment "comment" */ code
code "string /* string */ // string" code
code // comment
"string"
code /* comment
"comment" */ code
code "string
/* comment */ // comment" string
code "string\
/* string */ // string" code
code // comment // comment
code /* comment /* comment */ code */
code "string \" string" code "string" code
推荐答案
我认为从全局意义上讲这是不可能的(不仅仅是在示例中).因此,regexp不能用于语法高亮显示.
I think it's impossible in global sense (not just on the sample). So, regexp cann't be used for syntax highlighting.
这篇关于语法突出显示正确的正则表达式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!