47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#include <print>
|
|
// #include "../utils/snplib_string.h"
|
|
// #include "../include/snipplib/snplib_string.h"
|
|
#include <snipplib/utils/snplib_string.h>
|
|
|
|
using namespace snplib;
|
|
int main()
|
|
{
|
|
std::string si = " dewf wek e lwekjflkj ";
|
|
|
|
auto s = snplib_trim_spaces(si);
|
|
|
|
std::println("s = '{}'", s);
|
|
|
|
auto sv = snplib_trim_spaces_as_view(si, TrimType::TRIM_LEFT);
|
|
|
|
std::println("sv(TrimType::TRIM_LEFT) = '{}'", sv);
|
|
|
|
sv = snplib_trim_spaces_as_view(si, TrimType::TRIM_RIGHT);
|
|
|
|
std::println("sv(TrimType::TRIM_RIGHT) = '{}'", sv);
|
|
|
|
sv = snplib_trim_spaces_as_view(si, TrimType::TRIM_BOTH);
|
|
|
|
std::println("sv(TrimType::TRIM_BOTH) = '{}'", sv);
|
|
|
|
|
|
si = "123; we; d34534; ";
|
|
|
|
std::vector<std::string_view> rv;
|
|
rv = snplib_split_char_range<decltype(rv)>(si, "; ");
|
|
|
|
std::println("\n\nstr = '{}'", si);
|
|
|
|
std::println("all elems: ");
|
|
for (auto& el : rv) {
|
|
std::println("el = '{}'", el);
|
|
}
|
|
|
|
rv = snplib_split_char_range<decltype(rv)>(si, "; ", 1, 2);
|
|
std::println("2 elems starting from 1: ");
|
|
for (auto& el : rv) {
|
|
std::println("el = '{}'", el);
|
|
}
|
|
|
|
return 0;
|
|
} |