Reputation: 55
I'm trying to separate a string in the following format,
STANDARDWOFFPACK_FACULTY ; FLOW_FREE
So that each entry in the string is an item within an array I can iterate through to do a function against. Any suggestions on how I would achieve this array would be greatly appreciated.
Upvotes: 0
Views: 67
Reputation: 8442
You can use the split()
method:
$myString= 'STANDARDWOFFPACK_FACULTY ; FLOW_FREE'
$myString.split(';')
Which gives:
STANDARDWOFFPACK_FACULTY
FLOW_FREE
Note that this includes the extra spaces as part of the separate strings. If you want rid of those, do this:
$myString.split(';').Trim()
To get the output in an array, simply capture it in a variable:
$myArray = $myString.split(';').Trim()
You can confirm it is an array with the GetType()
method:
$myArray.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Upvotes: 1