# splitString ## Category String ## Arity **Binary** — ` splitString `. Also accepts array form: `splitString [string, separator]`. ``` splitString splitString // [string, separator] ``` ## Description Splits a string by the given separator into an array of substrings. Returns the array. If the separator is not found, returns an array with the original string as the single element. ## How It Works Calls `string.Split(separator, StringSplitOptions.None)` with ordinal comparison. Empty strings between consecutive separators are preserved (unlike `StringSplitOptions.RemoveEmptyEntries`). ## Usage ### Basic split ```sqf "a,b,c" splitString ","; // ["a", "b", "c"] splitString ["a,b,c", ","]; // same, array form ``` ### CSV parsing ```sqf _line = "John,Doe,42,Engineer"; _fields = _line splitString ","; _name = _fields select 0; // "John" _age = parseNumber (_fields select 2); // 42 ``` ### Path splitting ```sqf _path = "scripts\ai\combat.sqf"; _parts = _path splitString "\"; _filename = _parts select (count _parts - 1); // "combat.sqf" ``` ### Multi-character separator ```sqf _data = "key=value;name=test;hp=100"; _pairs = _data splitString ";"; _pairs forEach { _kv = _x splitString "="; systemChat f"{_kv select 0} -> {_kv select 1}"; }; ``` ### Word splitting ```sqf _words = "the quick brown fox" splitString " "; count _words; // 4 ``` ## Thread Safety ReadOnly — pure computation, returns new array. Safe from any scheduler. ## See Also - [joinString](joinString.md) — reverse: join array into string - [find](find.md) — find substring position - [in](in.md) — substring check - [select](select.md) — access characters