Powershell string filtering

I run a cmdlet in powershell which returns a string eg;

123@#EXT#outlook.com
456@outlook.com
789@outlook.com

I’m looking for a way to remove the #EXT# characters from the string. I can do everything but remove this and am struggling to find any documentation :/

>Solution :

Lets assume the cmdlet outputs an array of strings. This is simulated by the $adr variable.

#Array of strings
$adr = @(
    "123@#EXT#outlook.com"
    "456@outlook.com"
    "789@outlook.com"
)

$adr|foreach {$_ -replace "#EXT#",""}

Leave a Reply