xtd 0.2.0
Loading...
Searching...
No Matches

◆ split() [4/5]

std::vector< ustring > xtd::ustring::split ( const std::vector< value_type > &  separators,
string_split_options  options 
) const
noexcept

Splits this string into substrings based on the characters in an array. You can specify whether the substrings include empty array elements.

Parameters
separatorsA character array that delimits the substrings in this string, an empty array that contains no delimiters.
optionsxtd::string_split_options::remove_empty_entries to omit empty array elements from the array returned; or None to include empty array elements in the array returned.
Returns
An array whose elements contain the substrings in this string that are delimited by one or more characters in separators. For more information, see the Remarks section.
Remarks
Delimiter characters are not included in the elements of the returned array.
If the specified string does not contain any of the characters in separator, or the count parameter is 1, the returned array consists of a single element that contains the specified string.
If the specified string does not contain any of the characters in separator, the returned array consists of a single element that contains the specified string.
If the options parameter is remove_empty_entries and the length of the specified string is zero, the method returns an empty array.
Each element of separator defines a separate delimiter that consists of a single character. If the options argument is none, and two delimiters are adjacent or a delimiter is found at the beginning or end of the specified string, the corresponding array element contains empty string. For example, if separator includes two elements, "-" and "_", the value of the string instance is "-_aa-_", and the value of the options argument is None, the method returns a string array with the following five elements:
  1. empty string, which represents the empty string that precedes the "-" character at index 0.
  2. empty string, which represents the empty string between the "-" character at index 0 and the "_" character at index 1.
  3. "aa",
  4. empty string, which represents the empty string that follows the "_" character at index 4.
  5. empty string, which represents the empty string that follows the "-" character at index 5.
If the separator parameter contains no characters, white-space characters are assumed to be the delimiters. White-space characters are defined by the c++ standard and return true if they are passed to the xtd::char_object::isspace() or std::iswspace() method.
If count is greater than the number of substrings, the available substrings are returned.