regex - regular expression to match multiline text including delimiters -
I want to get data between delimiter and add delimiter to match.
Example text:
& gt; & Gt; & Gt; Possible error due to segmentation error in providing detection report: & lt; Detect-report & gt; It is already in the report. Just one example report & lt; / Detection-reports & gt; --------------------------------------------- Have a good day < / Code> My current code is:
if ($ oopsmessage = ~ / (? & Lt; = & lt; address-report & gt;) (( . | | \ N | \ r | \ s) +) (? = & Lt; \ / detection-report & gt;) /) {$ this-> {'Detect_report'} = $ 1; } This receives the following:
There is something already in the report. Just an example report. How can I include both detection-report delimiters?
You can simplify regex in the following:
My ($ Report) = $ oopsmessage = ~ m {(& lt; address-report & gt; *? & Lt; / trace-report & gt;)}; Information I used a different delimiter to avoid "tilt toothpick syndrome".
creates s modifier Match Newlines. The bracket force list reference in the ($ report), so the match returns to all matching groups $ 1 hence $ report Is assigned to.
Comments
Post a Comment