Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Question On Splitting A String In Powershell

$
0
0

I've been reading about the "Split" operator in PowerShell. (http://technet.microsoft.com/en-us/library/hh847811.aspx)

Based on what was in that article, it looks like I need a delimiter to split a string. The problem is that all of the examples show multiple words with a delimiter of, for example, a comma. What I am looking to do is split a single word and then put the information into variables.

ex.

If I have the following string which a user enters "CarTruckMotorcycleBoat" I want to split this at the end of character 3, 8, 18 and 22 and then store each string in a variable so that I essentially get:

$var1 = Car

$var2 = Truck

$var3 = Motorcycle

$var4 = Boat

I would split at 3, 8, 18 and 22 every single time.Does anyone know of a way that I can do this?


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images