Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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#",""}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading