Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

replace character to spaces in different position

$
0
0

Hello, i have a lot of txt files with this content:

ER-MD122-20150           001001/    0A0126070320120228I01A4
ER-MD129-20151           001001/    0A0126070320120228I01A4
ER-MD129-20152           001001/    0A0126070320120228I01A4
ER-MD129-20153           001001/    0A0126070320120228I01A4
ER-MD129-20154           001001/    0A0126070320120228I01A4

the three block are separate by multiple spaces.

I need to parse every lines in txt and remove the non numeric characters  at the beginning of line(in this case 5 character ER-MD). The number of non-numeric character may vary in other files.
Then i need to insert between first and second block a number of spaces equivalent to the characters removed earlier.

The file shouls appears:

129-20150                001001/    0A0126070320120228I01A4
129-20151                001001/    0A0126070320120228I01A4
129-20152                001001/    0A0126070320120228I01A4
129-20153                001001/    0A0126070320120228I01A4
129-20154                001001/    0A0126070320120228I01A4

between first (129-20150) and second block (001001/) five whitespaces are been added.

It is possible in powershell?

Thank you in advance




Viewing all articles
Browse latest Browse all 21975

Trending Articles