简体   繁体   English

在不知情的情况下使用相同元素两次的正则表达式

[英]regular expression with the same element twice without knowing it

I've plenty fill and want to find all of them which are like this:我有很多东西,想找到所有这样的:

A = A + B

So I wanna use a regular expression using M + x rgrep .所以我想使用正则表达式使用M + x rgrep and was thinking to something like that: ([A-Za-z][A-Za-z0-9]*) = () + [A-Za-z][A-Za-z0-9]* where () create a group which can be used latter.并且正在考虑类似的事情: ([A-Za-z][A-Za-z0-9]*) = () + [A-Za-z][A-Za-z0-9]*其中()创建一个以后可以使用的组。

Their is a way to make a regular expression where two item must be the same but without knowing the form of them?他们是一种制作正则表达式的方法,其中两个项目必须相同但不知道它们的形式?

I think you want something like this,我想你想要这样的东西,

([A-Za-z][A-Za-z0-9]*) = \1 \+ [A-Za-z][A-Za-z0-9]*

DEMO演示

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

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