关于java的正则表达式的一些疑惑……

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于java的正则表达式的一些疑惑……相关的知识,希望对你有一定的参考价值。

我看的程序有这样一个正则表达式
String regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
别的我都能看懂,只要是这个“.” "."在正则表达式里是全部的意思,
“\.”不就是说明了它有特殊的含义吗?为什么要加俩个“\\”了??
而“\w”在正则表达式里表示用于标识符的字符,为什么只加一个“\”??
API 里是这样写的
预定义字符类
. 任何字符(与行结束符可能匹配也可能不匹配)
\d 数字:[0-9]
\D 非数字: [^0-9]
\s 空白字符:[ \t\n\x0B\f\r]
\S 非空白字符:[^\s]
\w 单词字符:[a-zA-Z_0-9]
\W 非单词字符:[^\w]

为什么". " 比"\w"用时多一个“\”这个呢?!说到底,我是不懂斜杠的真正的用法,请您帮忙看看!谢谢了!
按照你说的,那么在时间里面为什么输出这样的格式2009/04/11 时,字符串是这样写的SimpleDateFormat sdf1 = new SimpleDateFormat("yy/MM/dd");这里是一个/呀?!我真的不懂,帮忙看看,谢谢!!!

你说的“.” 你说/是转义的么那么“/.”不就把“.”转义了吗?怎么还要俩个//了?!不懂,谢谢了!!!帮忙看看!

在JAVA中\是转义符,有些字符表示了一些特殊的用法,比如n,如果是\n,就把n转义成了特殊字符,\n在JAVA中就表示换行。

正则中,\d表示数字,\d中的\是真实的\,而到了JAVA的字符串中表示转义符,那怎么办呢?那我们就在\d前面再加一个\,再转义一次,就把原来的转义符取消了,就表示真正的\了。

.在正则中表示任何字符除了.本身,如何表示.本身呢?就需要在.前面加\,然而由于上述的原因,所以又需多加一个\。当你看JAVA写的正则时,你就把\\当一个\理解就可以了。

你可以理解为双重\,如果在正则中有个\的,在JAVA中,就把他变成两个\\,就是JAVA把他多加一层。
参考技术A ,wholesale gucci hoodies 2 Coco Chanel Biography y
For more information and options that are available for you online search can be quite useful for you to purchaseChanel wallets. Modern technology has provided us with many benefits that have made our life easy. A click of a button and an entire range of options come to play where you can search and order any product or services within no time. Such a benefit is not available while you have to spend time and effort to search for a wallet according to your requirements and with the help of online search you will have several options to search, compare and order the required wallet with much less effort, while availing some potential online ordering discount.

If we say that the brand speaks for its own quality and prestige, it would not be wrong. Therefore, if you are among those people who only go for branded stuff Chanel wallets is the best choice to acquire as the brand speaks for itself and show a class to what you are holding. Several celebrities are often spotted to be possessing wallets which are branded and Chanel comes on the top list. Long and well reputed history has made Chanel the bestselling brand where it is considered to be a symbol of quality and style. Variations in style and extensive options make it possible to purchase the wallet that is just right as par your requirements. Whereas,wholesale Chanel 1 The cheap chanel clothing f, Chanel wallets are easily available around the globe and their name suggests that it has to be something of class and quality.

When you feel the need to keep yourself up to date with all the latest fashion trends, there are quite a few options that can be considered in that respect and such an example would be of wallets that can be added as a cool contribution to your dress and personality.

Where it is said to be wallets, Chanel wallets are the best to acquire for such purpose. These are available in extensive varieties and you have an additional option to choose between different sizes, shapes,Chanel Clothing 0 They say two heads are better than one, and wholesale Ralph La,guccci sandal, colors and price tags. However, if you would like to choose along with a particular dress matching with it would not be a problem as Chanel wallets are offered in several trendy and colors to satisfy the individual taste. People who are know how branded chanel wallets can make a difference to their personality and the trademark such as Chanel is one of the well known brands that do not need any explanation.

以上是关于关于java的正则表达式的一些疑惑……的主要内容,如果未能解决你的问题,请参考以下文章

尝试在java中使用正则表达式时堆栈溢出

Java:在正则表达式查询中使用占位符

关于python爬虫经常要用到的一些Re.正则表达式

关于正则表达式问题

关于正则表达式和通配符区别

关于正则表达式的问题