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
,...)
推荐答案
如果你想要点或其他特殊字符在regex中意味着是一个正常的角色,你必须用反斜杠来逃避它。由于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屋!
查看全文