[英]Extracting matches with Perl regex
I am trying to extract the following string RL2.OPT.TEST.01
from this one a lot of text...[RL2.OPT.TEST.01]<some more text
. 我试图从这一个
a lot of text...[RL2.OPT.TEST.01]<some more text
提取以下字符串RL2.OPT.TEST.01
a lot of text...[RL2.OPT.TEST.01]<some more text
。 Basically there can be anything before the RL2.
基本上
RL2.
之前可以有任何东西RL2.
but it always begins with RL2.
但它始终以
RL2.
开头RL2.
, and always finish by either ]
, <
, or a space. ,并始终通过
]
, <
或空格完成。
I tried with the following regex: m/RL2\\..*[\\s<\\]]+?$/g
but even if it finds a match for the string -- [RL2.OPT.TEST.01]
, it does not work for -- [RL2.OPT.TEST.01] some more text
. 我尝试使用以下正则表达式:
m/RL2\\..*[\\s<\\]]+?$/g
但即使找到字符串匹配-- [RL2.OPT.TEST.01]
,它-- [RL2.OPT.TEST.01]
不适合-- [RL2.OPT.TEST.01] some more text
。
I need an array of all the resultings matches in the large string I have. 我需要一个包含大字符串中所有结果匹配的数组。 I think I should also mention that this string has a lot of newline characters, but never in the middle of the strings I am trying to extract.
我想我还应该提一下,这个字符串有很多换行符,但从不在我试图提取的字符串中间。
Any clue about what is wrong with my regex? 关于我的正则表达式有什么问题的任何线索?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.