Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Trim first character from a file without using string methods

$
0
0

Hi,

I have a file with every line starts with ~(tilde) symbol. I want to trim only the very first tilde (~) in the very first line of the file. I dont want to save the file contents to a string variable and do that.. becoz the file formatting and text alignment gets lost after storing into a string. I want to preserve the file alignment and just remove the first occurrence of ~ character. I tried a lot of googling, everyone suggests to use string functions.

Here is the sample of my file.

~123611|Line1|66624|text text text text text text text text text|123456|text text text text text|

            |formatted aligned text formatted aligned text|

|formatted aligned text|formatted aligned text|formatted aligned text|formatted aligned text|

                 formatted aligned text|text text text text text text text text text

~923467|Line2|66624|text text text text text text text text text|123456|text text text text text|

            |formatted aligned text formatted aligned text|

|formatted aligned text|formatted aligned text|formatted aligned text|formatted aligned text|

                 formatted aligned text|text text text text text text text text text


Viewing all articles
Browse latest Browse all 6937

Trending Articles