[英]Exclude certain characters using RegEx
Try as I might, I can't get a RegEx to exclude space or single quotes. 尽我所能,我无法获得RegEx来排除空格或单引号。
I'd use PATINDEX if I was in SQL. 如果我在SQL中,我会使用PATINDEX。
Or NOT a positive match on either space or single quote, if I could negate... 如果我可以否定的话,或者不是空格或单引号的正面匹配......
I've tried (for single quote only) 我试过了(仅限单引号)
\\w*[^']\\w*
^\\w*[^']\\w*$
Please put me out of my misery so I can sleep tonight. 请把我从痛苦中解救出来让我今晚能入睡。
Edit: 编辑:
^[^\'\ ]*$? ?
Quite simple. 非常简单。 Does not allow empty strings. 不允许空字符串。
^[^' ]+$
i think this 我认为这
^\w*$
should work as \\w
does not include single quote or space. 应该工作为\\w
不包括单引号或空格。
没有阅读细节,我在那里看不到[^'](有空格和单引号)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.