Split(string, bool, string)

The Split(string, bool, string) function splits a string on a specified separator character or set of characters and returns a string collection. This function is an overload of Split(string, string).

Syntax

  Copy imageCopy Code
collection<string> Split(
  string source,
  bool charsNotInSet,
  string charSet
);

Parameters

source

The string to split.

charsNotInSet

Specifies whether the source string is split at the characters belonging to CharSet, or to the complement of CharSet (the set of characters that do not belong to CharSet).

charSet

The set of characters at which the source string is split when the value of CharsNotInSet is set to false. When the value of CharsNotInSet is set to true, the source string is split at the complement of CharSet.

If an empty string is passed in, then the separator character is a comma.

Return Values

Returns a collection of string values. Use the foreach keyword to iterate through the collection. If no member of charSet is found, this function returns the original string value as the single element in the collection.

Remarks

Adjacent characters belonging to CharSet are treated as a single separator.

Example Code

Assuming a set of SIP URIs that include the optional port and param values, the following code example splits the URIs on the ":" (colon) and ";" semicolon symbols, returning the URI scheme as the first element, the SIP address as the second element, the port number as the third element, and the URI parameter as the fourth element in the collection.

  Copy imageCopy Code
foreach (fullSIPuri in Split(GetUri(sipRequest.From), "false", ";:") {...}