Java RegEx 元字符 (.) 和普通点? [英] Java RegEx meta character (.) and ordinary dot?
本文介绍了Java RegEx 元字符 (.) 和普通点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java RegEx中,如何找出.
(点)我们在任何句子中使用的元字符和普通点之间的区别.如何处理其他元字符的这种情况,比如 (*
,+
,d
,...)
In Java RegEx, how to find out the difference between .
(dot) the meta character and the normal dot as we using in any sentence. How to handle this kind of situation for other meta characters too like (*
,+
,d
,...)
推荐答案
如果您希望正则表达式中的点或其他具有特殊含义的字符成为普通字符,则必须使用反斜杠对其进行转义.由于 Java 中的正则表达式是普通的 Java 字符串,因此您需要对反斜杠本身进行转义,因此您需要两个反斜杠,例如\.
If you want the dot or other characters with a special meaning in regexes to be a normal character, you have to escape it with a backslash. Since regexes in Java are normal Java strings, you need to escape the backslash itself, so you need two backslashes e.g. \.
这篇关于Java RegEx 元字符 (.) 和普通点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文