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

Removing initial space from reversed string?

$
0
0

I cant figure this out. Powershell running in PowerGUI

I have names that can be like either below stored in a variable $a

SMITH, JOHN A.
or
SMITH, JOHN

This almost works: $Reverse=(New-ObjectRegEx'[^\,]+','RightToLeft').Matches($a)-join' '
but the output has the leading space after the comma and before the first name and appears like this when I write-host $Reverse

 JOHN A. SMITH
 JOHN SMITH

How can I change it so it does not include the space at the beginning?

JOHN A. SMITH
JOHN SMITH

Thanks!




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>