Osy#the first language built for agents
Agents firstAgentic appsWorkflowsDurable Execution — built inSecurityTestingThe editorThe UI modelOne program

Reference / Function

Text.Split

Text.Split(s, separator) → List<string> (the substrings, StringSplitOptions.None)

The C# string.Split: breaks a string on a separator and returns the substrings as a List<string> — iterable with foreach and queryable with .Count / .Contains. Empty segments are kept, exactly like C#'s StringSplitOptions.None. Runs in memory only.

stable1 example compiled by CIfunctiontextstdlibcollection

Summary#

Text.Split(s, separator) splits s on each occurrence of separator and returns the substrings as a List<string> — the mutable-list shape, so the result is iterable with foreach and supports .Count and .Contains. This is the inverse of string.Join, and mirrors C#'s string.Split(separator) with StringSplitOptions.None: empty segments are kept.

Signature#

Text.Split(<string> s, <string> separator) -> List<string>

Description#

The result is a real List<string> (not a read-only query result), so the collection surface applies: foreach, .Count, .Contains, and passing it to string.Join. Membership and iteration are the idiomatic ways to consume it.

Empty handling is C#-faithful (StringSplitOptions.None): Text.Split("a,,b", ",") yields three elements ["a", "", "b"], and Text.Split("", ",") yields a single empty element [""].

Text.Split is in-memory only — a split produces a set, which has no SQL push-down form, so it is called on locals inside a function body, never inside a query predicate.

Examples#

List<string> TrimFields(string csv) {
  var trimmed = new List<string>();
  foreach (var field in Text.Split(csv, ",")) {
    trimmed.Add(Text.Trim(field));
  }
  return trimmed;
}
// TrimFields("orders, customers , items")  ->  ["orders", "customers", "items"]

See also#

Related

String interpolation & format specifiers

Build a string from literal text and embedded expressions with $"…{expr}…". A hole may carry a .NET format specifier…

Text.LastIndexOf

The C# string.LastIndexOf: the index of the LAST ordinal occurrence of a substring, or -1 if absent. The 3-arg overload…