|No such thing as a small change|
Re^7: Regex problems using '|'by moritz (Cardinal)
|on Jul 22, 2008 at 13:06 UTC||Need Help??|
i.e. where are my expectations wrong?
You seem to assume that, for an alternation $a|$b, the regex engine does the following:
Perhaps you want something along this line:
That searches for the Remediation Report\n\n(.+?)\n part of the regex anywhere in your string, and only if that fails it tries the second regex.
The record in question is one large string with newlines inside it
In the example script I posted, yes.
I updated the example data above to explain how each record is broken up better. I think the Data::Dumper output was a bit confusing. There is only one vulnerability name in each record, so /g shouldn't apply (I believe).
In scalar context the /g modifier doesn't mean "match as often as you can", but rather "start your match at pos $str, and set pos $str after the match". That means you can say stuff like this:
But it's not the only application. You can use it to preserve the pos $str value, and then apply a different regex against it.