i need regular expression which is not allow '
我需要正则表达式,这是不允许的
2 个解决方案
#1
2
If you want to say "match any character but zzz," use [^].
如果你想说“匹配任何字符,但打鼾声,”使用[^]。
[^']+
will match one or more characters, up until it hits a '.
(^)+将匹配一个或多个字符,直到它到达一个“。
If you want to make sure the entire string does not contain the specified character:
如果要确保整个字符串不包含指定的字符:
^[^']*$
#2
1
This will match only strings that do not contain a single quotation mark (your question is very unspecific so I have no idea if that's what you want, please be as specific as possible and describe what you really want to do):
这将只匹配不包含单引号的字符串(您的问题非常不明确,所以我不知道这是否是您想要的,请尽可能具体,并描述您真正想做的):
/^[^']*$/
#1
2
If you want to say "match any character but zzz," use [^].
如果你想说“匹配任何字符,但打鼾声,”使用[^]。
[^']+
will match one or more characters, up until it hits a '.
(^)+将匹配一个或多个字符,直到它到达一个“。
If you want to make sure the entire string does not contain the specified character:
如果要确保整个字符串不包含指定的字符:
^[^']*$
#2
1
This will match only strings that do not contain a single quotation mark (your question is very unspecific so I have no idea if that's what you want, please be as specific as possible and describe what you really want to do):
这将只匹配不包含单引号的字符串(您的问题非常不明确,所以我不知道这是否是您想要的,请尽可能具体,并描述您真正想做的):
/^[^']*$/