Java正则表达式1 = 1 [英] Java Regular expression for 1=1

查看:125
本文介绍了Java正则表达式1 = 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要查找java regex模式,它找到格式为1 = 1的输入字符串,其中=前缀应该具有相同的后缀数字。这里还有前缀&后缀值应该相同,如1 = 1,11 = 11,223 = 223。 1 = 2,3 = 22,33 = 22之类的值不应与模式匹配

I need to look for java regex pattern that finds input string in the format of 1=1 where prefix of "=" should have same count of digits with the suffix. Also here both prefix & suffix values should be the same like 1=1, 11=11, 223=223. Values like 1=2, 3=22, 33=22 should not match the pattern

我们是否可以使用一般模式来满足上述规则。

Can we have a general pattern to satisfy above rules.

推荐答案

使用后退参考:

(\d+)=\1\b

当然,在java中你需要逃避回来斜杠:

of course, in java you need to escape the back slashes:

"(\\d+)=\\1\\b"

这篇关于Java正则表达式1 = 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆