After executing the below command my powershell pegged at 97% CPU and completely froze. I am able to consistently reproduce this behavior. Any idea if it’s a bug or have I done some no-no?
$anew -match '((.*)+([v]\d{1}\.\d{1}\..*)$)'
$anew is an array of about 35 lines long, which holds config dump from a server. It looks similar to this:
Directory: \aaa.net\builds\directedbuilds\bbbb\ccc\dddd\eee
Mode LastWriteTime Length Name
—- ————- —— —-
d—- 10/15/2012 6:12 PM v2.1.0.69
Environment : AB-34
Servers_in_Environment : SERVER01;SERVER02
NgatRootFolder : E:\DIRNAME
PFXfilename : star.dom.net.pfx
etc…
Your pattern starts with
(.*)+, this is likely to lead to O(n3) performance, due to backtracking. You should probably use(^(.*)([v]\d{1}\.\d{1}\..*)$)(no extra +, and anchored) to avoid issues with very slow backtracking evaluation.