A delimiter for splitting into equal‐length strings.
Synopsis
Declared in <absl/strings/str_split.h>
class ByLength;
Description
The length argument to the constructor must be greater than 0.
Note: this delimiter works with single‐byte string data, but does not work with variable‐width encodings, such as UTF‐8.
Example:
using absl::ByLength; std::vector<std::string> v = absl::StrSplit("123456789", ByLength(3)); // v[0]== "123", v[1]== "456", v[2]== "789"
Note that the string does not have to be a multiple of the fixed split length. In such a case, the last substring will be shorter.
using absl::ByLength; std::vector<std::string> v = absl::StrSplit("12345", ByLength(2));
// v[0]== "12", v[1]== "34", v[2]== "5"