Part-2: Text Manipulation in PowerShell using .ToLower and .ToUpper method
Part-3: Text Manipulation in PowerShell using .StartsWith() and EndsWith() methods
Hi,
Today we are using .replace and .remove methods to play with the string. Lets start. Today i am using some fake email id as text.
$text = Aman.Dhally@xyz.com
lets assume that we have a text file which contain list of all users email id in our “XYZ” company and we want to remove “@xyz.com” and keep the text before “@xyz.com” .
Remove
Before doing anything else first lets check the length of our text using Length property. The syntax for remove method is to define to keep the number of characters and remove everything else. Not getting my point.. let ,me show to you.
Our text have 19 characters in it.
$text.Remove(11)
Now i am keeping 11 characters of the string and removing everything else. and you can see that the output is “Aman.Dhally” which are exactly 11 characters .
there is another example of Remove() method.
Video:
Thanks for reading
Aman Dhally
Hello how can i remove the last 2 digits of my string:
[string]$text = “Archive_Testebene1_20120228_124556”
$text.Length
$text.Remove(4)
With remove it only remove the first 4
Hi Jan
To remove the last 2 digits try
$text.Remove(32)