0

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.