.oslTokenise()

Description

oslTokenise splits a string into an array of tokens, respecting quoted strings as single tokens. This is particularly useful for parsing command-like strings where some arguments might contain spaces.

Parameters

oslTokenise takes no parameters.

Usage On Strings

str = 'hello "world is cool" lol'

log str.oslTokenise()
// ["hello", "\"world is cool\"", "lol"]
// splits by spaces but keeps quoted sections together

str2 = 'command arg1 "arg with spaces"'
log str2.oslTokenise()
// ["command", "arg1", "\"arg with spaces\""]
// useful for parsing command-like strings

str3 = 'simple no quotes'
log str3.oslTokenise()
// ["simple", "no", "quotes"]
// works like normal split when no quotes present

Last updated

Was this helpful?