I've got a powershell script to match the following regex:
---\n(0[1-9]|1[0-2][\/](0[1-9]|[12]\d|3[01])[\/]\d{2}[\s\S]+?)-----
The string to match from is the following logfile snippet:
-------------------------------------------------------------------------------
10/26/16 11:41:26 - Process(15925376.4) User(mqm) Program(amqzmuc0)
Host(aixmq1) Installation(Installation1)
VRMF(8.0.0.4) QMgr(ecs.queue.manager)
AMQ6287: WebSphere MQ V8.0.0.4 (p800-004-151017).
EXPLANATION: WebSphere MQ system information: Host Info :-
AIX 7.1 (MQ AIX 64-bit) Installation :- /usr/mqm (Installation1)
Version :- 8.0.0.4 (p800-004-151017) ACTION: None.
-------------------------------------------------------------------------------
10/26/16 11:41:26 - Process(15925376.4) User(mqm) Program(amqzmuc0)
Host(aixmq1) Installation(Installation1)
VRMF(8.0.0.4) QMgr(ecs.queue.manager)
AMQ6287: WebSphere MQ V8.0.0.4 (p800-004-151017).
EXPLANATION:FFF WebSphere MQ system information: Host Info :-
AIX 7.1 (MQ AIX 64-bit) Installation :- /usr/mqm (Installation1)
Version :- 8.0.0.4 (p800-004-151017) ACTION: None.
-------------------------------------------------------------------------------
Using this regex in perl and on regexr.com, it perfectly matches two sections from that logfile snippet.
Now i've implemented that same regex in powershell and it won't return any matches unless i remove the minuses preceding the \n. If i replace those minuses by a matching group that only contains minus, it will work aswell.
For the sake of consistency and understanding what is going on , i need to understand why the matching behavior is so different in powershell. Why won't it match as soon as there are minuses at the beginning?
The following .NET regex tester shows the same behavior as in powershell:
Could someone please explain to me why the matching behavior is that different in powershell compared to perl/regexr.com?
This is the snippet of powershell code i'm currently using to match that regex:
$matches = ([regex]::matches($sInput, "---\n(0[1-9]|1[0-2][\/](0[1-9]|[12]\d|3[01])[\/]\d{2}[\s\S]+?)\n-") | %{$_.value});