I have to search for files (around 2000) for the following string patern, which I do using grep as follows:
grep -irn ".acu" .
The response would be 100s of lines with the following pattern:
<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)
<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.
I am familiar with Lex-Yacc, and also looked into PLY but seems like an overkill. 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
(?s)(?<= ReturnVariable="xxx">\n<cfelse>\n)PATTERN(?=\n</cfif>)
where
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.