简体   繁体   English

使用正则表达式,如何在Java中查找比字符串大2位的数字

[英]Using Regular expression, how to find two digits great than a number in a string in Java

I have a string at most 1000 length, in the string every two digits represent a number, how can I find if the string contains a number that is great than my input number? 我有一个最大长度为1000的字符串,该字符串中的每两位数字代表一个数字,如何查找该字符串是否包含一个比输入数字大的数字?

eg 000102252500 represents numbers 00, 01, 02, 25, 25, 00, if I have an input number at 20(this number can be changed), how can I find if the string contains a number great than 20 using regular expression? 例如000102252500代表数字00、01、02、25、25、00,如果我输入的数字为20(可以更改此数字),如何使用正则表达式查找字符串是否包含大于20的数字?

Thanks! 谢谢!

With this regular expression you should match it but you must generate a regular expression to match all 2 digit numbers bigger than the input number in this case 20 which is inside the middle parenthesis. 使用此正则表达式,您应该将其匹配,但必须生成一个正则表达式以匹配大于输入数字的所有2位数字,在这种情况下,该数字在中间括号内为20。 (2[1-9])|([3-9][0-9]) //This matches any number from 21 to 99 (2 [1-9])|([3-9] [0-9])//此值可匹配21到99之间的任何数字

    ^(\d\d)*((2[1-9])|([3-9][0-9]))(\d\d)*$

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

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