Author Posts

April 27, 2017 at 11:34 am

I want to replace some strings in a generated HTML file, including some tag edits. Below is the code I am using:

$editreport -replace [regex]::Escape('employee(id','employeeid')
$editreport -replace [regex]::Escape('employeeType(id)','id')
$editreport -replace [regex]::Escape('employee(','employee')
$editreport -replace [regex]::Escape(')','')

I get the following errors (same message on all 4 replaces – below is one of them):

Cannot find an overload for "Escape" and the argument count: "2".
At line:1 char:1
+ $editreport -replace [regex]::Escape('employee`(id','employee ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

April 27, 2017 at 1:56 pm

what you try to achieve ?

[regex]::Escape should have only one argument

may be you want

$editreport -replace [regex]::Escape('employee(id'), 'employeeid'