简体   繁体   English

我怎样才能让这里的 \\\\.(....|..) 点只是数字 [\\\\.(....|..)0-9]? (Java)Regx,匹配?

[英]How can I make it so that here \\.(....|..) the points are only numbers [\\.(....|..)0-9]? (Java) Regx, matches?

have have the regx variable.matches("\\.(....|..)") .有 regx variable.matches("\\.(....|..)") Now my String needs to have a dot, and two or four characters after the dot.现在我的 String 需要有一个点,并且在点之后有两个或四个字符。 But my problem is, that I need that the characters are only Numbers from 0-9.但我的问题是,我需要字符只是 0-9 的数字。 For example I need that its only match when I have for instance:例如,当我有以下情况时,我需要它的唯一匹配:

.12 or .22 or .8389 or.3920 and not .dd or .d93j, so the characters after the dot needs to be numbers, but variable.matches("[\\.(....|..)0-9]") dont work, how we could fix that? .12 或 .22 或 .8389 或 .3920 而不是 .dd 或 .d93j,所以点后面的字符需要是数字,但variable.matches("[\\.(....|..)0-9]")不起作用,我们如何解决这个问题?

尝试这个:

"\\.(\d{2}|\d{4})"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM