[英]How to search files specific XML code pattern
I have to search for files (around 2000) for the following string patern, which I do using grep as follows: 我必须搜索以下字符串模式的文件(大约2000个),我使用grep的方式如下:
grep -irn ".acu" .
The response would be 100s of lines with the following pattern: 响应将是具有以下模式的100条线:
<cf_query Query="DSSQuery" Program="qdss.acu" xxx>
Then I will have check whether the line found (above), is surrounded by the xml tags as follows (xxx is irrelevant) 然后,我将检查找到的行(上方)是否被xml标记包围,如下所示(xxx不相关)
<cfif IsDefined("REQUEST.<STRING>") xxx>
<cfmodule
template="xxx"
Service="xxx"
Action="xxx"
QueryString="xxx"
ReturnVariable="xxx">
<cfelse>
<cf_query Query="DSSQuery" Program="qdss.acu" xxx>
</cfif>
If YES then I extract the <STRING>
and then I do something with the string. 如果是,则提取
<STRING>
,然后对字符串进行处理。
I am familiar with Lex-Yacc, and also looked into PLY but seems like an overkill. 我熟悉Lex-Yacc,也研究过PLY,但似乎有点过头了。 Can I get a pointer where to start with this, and any efficient way to achieve my goal.
我可以从这里开始找到指针,以及实现我的目标的任何有效方法。
You can use lookaround tags eg. 您可以使用环视广告代码,例如。 https://regex101.com/r/wF3nD3/2
https://regex101.com/r/wF3nD3/2
(?s)(?<= ReturnVariable="xxx">\n<cfelse>\n)PATTERN(?=\n</cfif>)
where 哪里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.