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 codeCopy 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 CharsNotInSetis set to false . When the value of CharsNotInSetis set to true , the source string is split at the complement of CharSet.

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

Return values

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

Remarks

Adjacent characters belonging to CharSetare treated as a single separator.

Example code

Assuming a set of SIP URIs that include the optional portand paramvalues, 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 codeCopy code
foreach (fullSIPuri in Split(GetUri(sipRequest.From), "false",
";:") {...}