I'm trying to replace a string input by a user. I have the following input (as a firstname, lastname)...
I am use the following code:
$userInput = $userInput -replace '\s','' $firstName = $userInput -replace ",*$","" $lastName = $userInput -replace "^*,",""
Output looks like the following:
$userInput = John,Doe $firstName = John,Doe $lastName = JohnDoe
I need the output to look like this:
$userInput = John,Doe $firstName = John $lastName = Doe
What am I doing wrong?