简体   繁体   English

REGEX - 如果您在两个连续的字符串上有相同的东西,如何提取

[英]REGEX - How to extract if you have the same thing on two consecutive strings

Since this weekend I'm stuck on a REGEX expression which must be simple I guess... Could you help me on the definition of the expression, please?由于这个周末我被困在一个 REGEX 表达式上,我想这一定很简单......你能帮我解释一下表达式的定义吗?

In the links below , I would simply like to catch the height="25"> only when two "height="25"> follow each other and find and replace it:在下面的链接中,我只想在两个“height="25">相互跟随并找到并替换它时捕获height="25">

https://regex101.com/r/Ly742Z/1 https://regex101.com/r/Ly742Z/1

I had thought of the following logic:我想到了以下逻辑:

  • If you find 2 "height="25"> on two consecutive strings (see below):如果您在两个连续的字符串上找到 2 "height="25"> (见下文):
  • Then grab the 2nd " height="25"然后抓住第二个“ height="25"

It gave me this for now: (" height="25">. \n). (?<=" height="25">)它现在给了我这个:(" height="25">。 \n)。 (?<=" height="25">)

What do you think about it?你怎么看待这件事?

Thanks!谢谢!

You can use this regex:您可以使用此正则表达式:

(" height="(.*)">.*\n)" height="\2">

Group 1 capture the first line第 1 组捕获第一行

Group 2 capture the height value第 2 组捕获高度值

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

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