Script hangs after replacing a lot of regexp's in a very large string - by sba

Status : 


Sign in
to vote
ID 779443 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 2/18/2013 8:14:07 AM
Access Restriction Public


I wrote a script to "clean up" data from an application logfile that contains Unicode characters in the middle of an ASCII string.

The logic is as follows:

    while ($str -match '(.*)(Wstring={[^}]*\000[^}]*})(.*)')
        $str = $matches[1] + ($matches[2] -replace '\000', '') + $matches[3]

On a particular file, the script hangs (and the PowerShell host consumes CPU).
Sign in to post a comment.