-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (31 loc) · 1020 Bytes
/
Copy pathmain.cpp
File metadata and controls
34 lines (31 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include "StringUtil.hpp"
#include "Format.hpp"
int main()
{
std::string str = "Hello world";
std::cout << StringUtil::trimLeft(str, "Hello") << std::endl;
std::cout << StringUtil::trimRight(str, "world") << std::endl;
str = " nihao ";
std::cout << StringUtil::trim(str) << std::endl;
std::cout << StringUtil::toUpper(str) << std::endl;
std::cout << StringUtil::toLower(StringUtil::toUpper(str)) << std::endl;
str = "Hello world";
std::cout << StringUtil::startsWith(str, "Hello") << std::endl;
std::cout << StringUtil::endsWith(str, "a") << std::endl;
std::vector<std::string> result = StringUtil::split(str, " ");
for (auto& iter : result)
{
std::cout << iter << std::endl;
}
try
{
std::string str = "a = {0}, b = {1}";
std::cout << format(const_cast<char*>(str.c_str()), 10.23, 200) << std::endl;
}
catch (std::exception& e)
{
std::cout << e.what() << std::endl;
}
return 0;
}