正则表达式" ^ [A-ZA-Z] QUOT;或QUOT; [^ A-ZA-Z] QUOT; [英] Regular expression "^[a-zA-Z]" or "[^a-zA-Z]"
本文介绍了正则表达式" ^ [A-ZA-Z] QUOT;或QUOT; [^ A-ZA-Z] QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有 ^ [A-ZA-Z]
和 [^ A-ZA-Z]
?
当我检查在C#中,
Regex.IsMatch("t", "^[a-zA-Z]") // Returns true (I think it's correct)
Regex.IsMatch("t", "[^a-zA-Z]") // Returns false
有使用大量的网站 [^ A-ZA-Z]
的字母表。我真的不知道哪一个是正确答案。
There are a lot of web sites using [^a-zA-Z]
for the alphabet. I'm not really sure which one is correct answer.
推荐答案
是的,第一个意思是匹配以字母开头的所有字符串,第二个意思是匹配的所有字符串包含一个非字母。插入符号(^)有两种不同的方式使用,一个信号文本的开始,一个否定方括号内的字符匹配。
Yes, the first means "match all strings that start with a letter", the second means "match all strings that contain a non-letter". The caret ("^") is used in two different ways, one to signal the start of the text, one to negate a character match inside square brackets.
这篇关于正则表达式" ^ [A-ZA-Z] QUOT;或QUOT; [^ A-ZA-Z] QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文