From bacda469418fd84254e2ef885d53c473d1b3fed9 Mon Sep 17 00:00:00 2001 From: Bruce Payette Date: Tue, 26 Jun 2018 12:27:16 -0700 Subject: [PATCH] Fix the pref regression to the '-replace' operator after adding ScriptBlock support (#7135) --- src/System.Management.Automation/engine/lang/parserutils.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index aba9d46c88..929afbb07e 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -908,7 +908,7 @@ namespace System.Management.Automation pattern = rList[0]; if (rList.Count > 1) { - substitute = rList[1]; + substitute = PSObject.Base(rList[1]); } } } @@ -972,6 +972,9 @@ namespace System.Management.Automation { switch (substitute) { + case string replacementString: + return regex.Replace(input, replacementString); + case ScriptBlock sb: MatchEvaluator me = match => { var result = sb.DoInvokeReturnAsIs(