Bin wrote:
> Hi,
>
> I have and input text file containing data in the following format:
>
> 9.00; 1.00-; .00000;00; 25.00; 672;SC;006700014414841;107/09/14;
> 19.00; 22.00-; .00000;00; 205.00;
> 672;SC;006700014414841;107/09/14;
>
> Is there any easy way to shift the negative sign (-) in the second column to
> left? Output text should be like this:
>
> 9.00; -1.00; .00000;00; 25.00; 672;SC;006700014414841;107/09/14;
> 19.00; -22.00; .00000;00; 205.00;
> 672;SC;006700014414841;107/09/14;
>
> Is there any easy way using regex or any search-replace technique?
>
> Any help much appreciated.
>
> Thanks,
> PN
> Easy enough... What do you want to do with the result? Create a 2nd
file with it? Overwrite the original? I'm assuming this is
line-per-line, and the general format doesn't change?
I've got something, but it isn't pretty yet...
PSH> $string
9.00; 1.00-; .00000;00; 25.00;
672;SC;006700014414841;107/09/14;
PSH> $string|`
foreach-object{$split=$split=$string.split(";")
$split[0]+";-"+$_.split(";")[1].trimend("-1").trimstart()}
9.00;-1.00
Ain't pretty, and I loose some of the spacing. A regex would be neater.
How do the original spaces fit into all of this? Do they need to be
preserved?
Marco
--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp
PowerGadgets MVP
http://www.powergadgets.com/mvp
Blog:
http://marcoshaw.blogspot.com