StringUtils
This library implements many commonly used but not natively supported function in std::string, like Split, Join, Trim, Compact, ReplaceAll, ToLower, ToUpper, Repeat, ReadFile, WriteFile, etc
Install / Use
/learn @hungtatai/StringUtilsREADME
StringUtils
This library implements many commonly used but not natively supported function in std::string, like Split, Join, Trim, Compact, ReplaceAll, ToLower, ToUpper, Repeat, ReadFile, WriteFile, etc.
Test
make test
Passing: Split(s, delim, false)
Passing: Split(s, delim, true)
Passing: Join(res, delim, false)
Passing: Join(res, delim, true)
Passing: Compact(res)
Passing: Trim(" hi ")
Passing: Repeat("-", 5)
Passing: ReplaceAll("monday morning", "mo", "kk")
Passing: ToUpper("abcd")
Passing: ToLower("ABCD")
Passing: ReadFile("test_readfile.txt")
Passing: WriteFile("test_writefile.txt", "abcde")
Result: 12/12 Completed.
Usage
see example: test.cpp
see source code: string-utils.h
see demo: demo
Split
vector<string> v = Split("one,two,three", ","); // v: ["one", "two", "three"]
Join
vector<string> v;
v.push_back("1");
v.push_back("2");
v.push_back("3");
string s = Join(v, ":"); // s: "1:2:3"
Trim
string s = Trim(" hi "); // v: "hi"
Repeat
string s = Repeat("#", 5); // v: "#####"
ReplaceAll
vector<string> v = ReplaceAll("1-2-3-4", "-", "#"); // v: "1#2#3#4"
Compact
remove empty string
vector<string> v;
v.push_back("1");
v.push_back("");
v.push_back("2");
v.push_back("3");
v.push_back("");
// v: ["1", "", "2", "3", ""]
v = Compact(v);
// v: ["1", "2", "3"]
ToLower
string s = ToLower("ABCD"); // v: "abcd"
ToUpper
string s = ToUpper("abcd"); // v: "ABCD"
ReadFile
read file to string
string content = ReadFile(...file path...);
WriteFile
write string to file
string content = "...";
WriteFile(...file path..., content);
Demo
build and run: make demo
see demo: demo
Contributing
We love contributions! If you'd like to contribute please submit a pull request.
License
Related Skills
openhue
344.4kControl Philips Hue lights and scenes via the OpenHue CLI.
sag
344.4kElevenLabs text-to-speech with mac-style say UX.
weather
344.4kGet current weather and forecasts via wttr.in or Open-Meteo
tweakcc
1.5kCustomize Claude Code's system prompts, create custom toolsets, input pattern highlighters, themes/thinking verbs/spinners, customize input box & user message styling, support AGENTS.md, unlock private/unreleased features, and much more. Supports both native/npm installs on all platforms.
