正则表达式中[[]]与`.`之间的区别 [英] Differences between`[.]` vs `.` in regex
本文介绍了正则表达式中[[]]与`.`之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下表达式不相同:/[.] */
和/.*/
.为什么会这样,它们到底有什么不同? []
和正则表达式中的特殊字符之间有什么相互作用?
The following expressions are not the same: /[.]*/
and /.*/
. Why is that, and how exactly are they different? What is the interaction between the []
and special characters in regular expressions?
谢谢.
推荐答案
点.
通常是通配符,匹配任何字符.但是,在字符类( []
)中,它被视为文字,并且仅与点匹配.
The dot .
is normally a wildcard, matching any character. Within a character class (the []
) however, it is treated as a literal and only matches a dot.
这篇关于正则表达式中[[]]与`.`之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文