I m using following reg exp for validating the name of function
我正在使用下面的reg exp来验证函数的名称
([a-zA-Z]\w+)[^\w]
ex addNumber is a valid function , while now for changed requirements user can also write local:addNumber .
ex addNumber是一个有效的函数,而现在对于已更改的需求,用户也可以写入local:addNumber。
I want to modify this regular expression in such a way so that it can allow single occurence of local:.
我想以这样的方式修改这个正则表达式,以便它可以允许出现局部:。
I tried but can't make a perfect one.
我试过了,但不能做出一个完美的。
1 个解决方案
#1
7
Doesn't using (local:)?([a-zA-Z]\w+)[^\w] fix your problem?
不使用(本地:)?([a-zA-Z]\ w +)[^ \ w]解决你的问题?
Edit: The regex in C# is actually (local\:)?([a-zA-Z]\w+)[^\w], because :(colon) is a special character that has to be escaped. Thank you Russ C
编辑:正则表达式在c#中实际上是(本地\:)?([a-zA-Z]\ w +)[^ \ w],因为:(结肠)是一种特殊的字符必须转义。谢谢Russ C
#1
7
Doesn't using (local:)?([a-zA-Z]\w+)[^\w] fix your problem?
不使用(本地:)?([a-zA-Z]\ w +)[^ \ w]解决你的问题?
Edit: The regex in C# is actually (local\:)?([a-zA-Z]\w+)[^\w], because :(colon) is a special character that has to be escaped. Thank you Russ C
编辑:正则表达式在c#中实际上是(本地\:)?([a-zA-Z]\ w +)[^ \ w],因为:(结肠)是一种特殊的字符必须转义。谢谢Russ C