1
1
1rayman12022-03-02 08:50:03
PowerShell
1rayman1, 2022-03-02 08:50:03

Powershell how to remove extra characters from a variable?

I get the text from the Word file into certain variables, but I came across the fact that in addition to the text in the variable there are a lot of line breaks and incomprehensible characters, please tell me how it is possible to clean up all unnecessary? At the moment, I settled on the fact that I remove all spaces and hyphens and cut off 1 character from the end, but somehow it does not always
work
correctly
. .ru
"line break"
"line break"
and of course I can't send anything to such an email, help kind people.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MaxKozlov, 2022-03-02
@1rayman1

Hard way - cut off everything that can't be in normal mail, like
$mail = $mail -replace '[^a-z0-9\.\[email protected]_=]' # what other characters are there....

1
1rayman1, 2022-03-02
@1rayman1

621f0664c275f843001882.png
this sign is not inserted in the text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question