Split(string, string)

The Split(string, string)function splits a string on a specified separator character and returns a string collection.

Syntax

  Copy codeCopy code
collection<string> Split(
  string source,
  string separator
);

Parameters

source

The string to split.

separator

A single-character string at which the source string is split. If separatorconsists of more than one character, only the first character is used and the function returns a separate element in the collection for each occurrence of this character, even if multiple occurrences of this character are adjacent to one another. If an empty string is passed in, then the separatorcharacter is a comma.

Return values

Returns a collection of string values. Use the foreachkeyword to iterate through the collection. If the separatorstring is not found, this function returns the original source string value as the single element in the collection.

Example code

The following code example splits a URI on the "@" (at) symbol, returning the username as the first element in the collection and the hostname as the second.

  Copy codeCopy code
foreach (userAndHost in Split(GetUri(sipRequest.From), "@"))) { ...
}