| 967 | } |
| 968 | |
| 969 | String String::get_slicec(char32_t p_splitter, int p_slice) const { |
| 970 | if (is_empty()) { |
| 971 | return String(); |
| 972 | } |
| 973 | |
| 974 | if (p_slice < 0) { |
| 975 | return String(); |
| 976 | } |
| 977 | |
| 978 | const char32_t *c = ptr(); |
| 979 | int i = 0; |
| 980 | int prev = 0; |
| 981 | int count = 0; |
| 982 | while (true) { |
| 983 | if (c[i] == 0 || c[i] == p_splitter) { |
| 984 | if (p_slice == count) { |
| 985 | return substr(prev, i - prev); |
| 986 | } else if (c[i] == 0) { |
| 987 | return String(); |
| 988 | } else { |
| 989 | count++; |
| 990 | prev = i + 1; |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | i++; |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | Vector<String> String::split_spaces(int p_maxsplit) const { |
| 999 | Vector<String> ret; |