{"id":20051899,"url":"https://github.com/p-ranav/strcpp.old","last_synced_at":"2025-07-29T03:08:31.921Z","repository":{"id":97290689,"uuid":"98037724","full_name":"p-ranav/strcpp.old","owner":"p-ranav","description":"String Manipulation API for C++","archived":false,"fork":false,"pushed_at":"2017-07-22T23:26:08.000Z","size":42,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T11:44:53.046Z","etag":null,"topics":["cpp","header-only","lightweight","mit-license","string-manipulation"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p-ranav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-07-22T14:48:42.000Z","updated_at":"2025-03-23T15:57:55.000Z","dependencies_parsed_at":"2023-06-26T09:00:48.153Z","dependency_job_id":null,"html_url":"https://github.com/p-ranav/strcpp.old","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/p-ranav/strcpp.old","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-ranav%2Fstrcpp.old","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-ranav%2Fstrcpp.old/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-ranav%2Fstrcpp.old/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-ranav%2Fstrcpp.old/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-ranav","download_url":"https://codeload.github.com/p-ranav/strcpp.old/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-ranav%2Fstrcpp.old/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267621600,"owners_count":24116900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","header-only","lightweight","mit-license","string-manipulation"],"created_at":"2024-11-13T12:07:43.083Z","updated_at":"2025-07-29T03:08:31.910Z","avatar_url":"https://github.com/p-ranav.png","language":"C++","readme":"# String Manipulation API for C++\n\n## strcpp::split\n\n```cpp\n{\n  std::string input = \"We are the champions\";     // input string\n  std::vector\u003cstd::string\u003e result;                // result vector\n\n  result = strcpp::split(input, \" \");             // result = [\"We\", \"are\", \"the\", \"champions\"]\n  result = strcpp::split(input, \" a\");            // result = [\"We\", \"re the champions\"]\n  result = strcpp::split(input, \"ions\");          // result = [\"We are the champ\"]\n\n  input = \"a, b, c, d, e\";\n  result = strcpp::split(input, \", \");            // result = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n\n  input = \"LOGGER::ERROR::Error Message!\";\n  auto message = strcpp::split(input, \"::\")[2];   // message = \"Error Message!\"\n}\n```\n\n## strcpp::join\n\n```cpp\n{\n  std::string input = \"This. is. not. how. sentences. work.\";        // wow such a sentence\n  auto split_string = strcpp::split(input, \". \");                    // split using period\n  std::string joined_string = strcpp::join(split_string, \" \");       // join result of split\n  std::string output = strcpp::replace(joined_string, \" not\", \"\");   // remove the word 'not'\n  std::cout \u003c\u003c output \u003c\u003c std::endl;                                  // \"This is how sentences work.\"\n\n  input = \"Transaction_date, Product, Price, State\";                 // some csv data\n  split_string = strcpp::split(input, \", \");                         // split using comma\n  output = strcpp::join(split_string, \"::\");                         // join result of split\n  std::cout \u003c\u003c output \u003c\u003c std::endl;                                  // \"Transaction_date::Product::Price::State\"\n}\n```\n\n## strcpp::slice\n\n```cpp\n{\n  std::string input = \"Hello World\";\n  // End index is optional and defaults to end of string\n  std::cout \u003c\u003c strcpp::slice(input, 0) \u003c\u003c std::endl;     // All but the first zero characters  - \"Hello World\"\n  std::cout \u003c\u003c strcpp::slice(input, 0, 1) \u003c\u003c std::endl;  // Just the first character           - \"H\"\n  std::cout \u003c\u003c strcpp::slice(input, 3) \u003c\u003c std::endl;     // All but the first three characters - \"lo World\"\n  std::cout \u003c\u003c strcpp::slice(input, 0, 5) \u003c\u003c std::endl;  // Just the first five characters     - \"Hello\"\n  std::cout \u003c\u003c strcpp::slice(input, 3, 8) \u003c\u003c std::endl;  // After third till eigth character   - \"lo Wo\"\n  std::cout \u003c\u003c strcpp::slice(input, -3) \u003c\u003c std::endl;    // Just the last three characters     - \"rld\"\n  std::cout \u003c\u003c strcpp::slice(input, 0, -3) \u003c\u003c std::endl; // All but the last three characters  - \"Hello Wo\"\n}\n```\n\n## strcpp::contains\n```cpp\n{\n  std::string input = \"ERROR::Houston, we have a problem!\";\n\n  if (strcpp::contains(input, \"ERROR\"))                                 // containment check - case sensitive\n    std::cout \u003c\u003c \"Input string contains \\\"ERROR\\\"\" \u003c\u003c std::endl;        // check returns true and prints message\n\n  if (strcpp::contains(input, \"error::\", true))                         // containment check - ignore case\n    std::cout \u003c\u003c \"Input string contains \\\"error::\\\"\" \u003c\u003c std::endl;      // check returns true and prints message\n\n  if (strcpp::contains(input, \"PROBLEM\"))                               // containment check - ignore case\n    std::cout \u003c\u003c \"Input string contains \\\"PROBLEM\\\"\\n\";\n  else\n    std::cout \u003c\u003c \"Input string does not contain \\\"PROBLEM\\\"\\n\";         // check returns false and prints message\n}\n```\n\n## strcpp::count\n\n```cpp\n{\n  std::string input = \"Hello World!\";\n  std::cout \u003c\u003c strcpp::count(input, \"l\") \u003c\u003c std::endl;                  // prints 3\n  std::cout \u003c\u003c strcpp::count(input, \"llo\") \u003c\u003c std::endl;                // prints 1\n  std::cout \u003c\u003c strcpp::count(input, \" W\") \u003c\u003c std::endl;                 // prints 1\n  std::cout \u003c\u003c strcpp::count(input, \" wo\") \u003c\u003c std::endl;                // prints 0\n  std::cout \u003c\u003c strcpp::count(input, \" wo\", true) \u003c\u003c std::endl;          // prints 1 - ignores case\n\n  std::string them_spaces = \"Count, the number of          spaces\";\n  std::cout \u003c\u003c strcpp::count(them_spaces, \" \") \u003c\u003c std::endl;            // prints 13\n}\n```\n\n## strcpp::starts_with\n\n```cpp\n{\n  std::string input = \"What's up with the Quaithe?\";\n  if (strcpp::starts_with(input, 'W'))\n    std::cout \u003c\u003c \"Input string starts with 'W'\\n\";                     // check returns true and prints message\n\n  if (strcpp::starts_with(input, 'w', true))\n    std::cout \u003c\u003c \"Input string starts with 'w' - Case is ignored\\n\";   // check returns true and prints message\n}\n```\n\n## strcpp::ends_with\n\n```cpp\n{\n  std::string input = \"What's up with the Quaithe?\";\n  if (strcpp::ends_with(input, '.'))                                   // check returns false\n    std::cout \u003c\u003c \"Input string ends with period\\n\";\n\n  if (strcpp::ends_with(input, '?'))                                   // check returns true and prints message\n    std::cout \u003c\u003c \"Input string is a question\\n\";\n}\n```\n\n## strcpp::repeat\n\n```cpp\n{\n  std::string input = \"Ha\";\n  std::cout \u003c\u003c strcpp::repeat(input, 5) \u003c\u003c std::endl;           // \"HaHaHaHaHa\"\n  std::cout \u003c\u003c strcpp::repeat(input, 5, \" \") \u003c\u003c std::endl;      // \"Ha Ha Ha Ha Ha\"\n\n  input = \"Ch\";\n  auto result = strcpp::repeat(\n                  strcpp::repeat(input, 2, \"ooo!\"), \n                3, \" \");\n  std::cout \u003c\u003c result \u003c\u003c std::endl;                             // \"Chooo!Chooo! Chooo!Chooo! Chooo!Chooo!\"\n\n}\n```\n\n## strcpp::find\n\n```cpp\n{\n  std::string input = \"I scream, you scream, we all scream for icecream!\";\n  size_t find_index = strcpp::find(input, \"you\");                            // Index = 10\n  std::cout \u003c\u003c find_index \u003c\u003c std::endl;\n}\n```\n\n## strcpp::find_first\n\n```cpp\n{\n  std::string input = \"I scream, you scream, we all scream for icecream!\";\n  size_t find_index = strcpp::find_first(input, \"cream\");                    // Index = 3\n  std::cout \u003c\u003c find_index \u003c\u003c std::endl;\n}\n```\n\n## strcpp::find_last\n\n```cpp\n{\n  std::string input = \"I scream, you scream, we all scream for icecream!\";\n  size_t find_index = strcpp::find_last(input, \"cream\");                     // Index = 47\n  std::cout \u003c\u003c find_index \u003c\u003c std::endl;\n}\n```\n\n## strcpp::find_regex\n\n```cpp\n{\n  std::string log(R\"(\n        Speed : 366\n        Mass  :\t 35\n        Speed : 378\n        Mass  :\t 32\n        Speed : 400\n\tMass  :\t 30)\");\n  std::string regex_string = R\"(Speed : \\d*)\";\n  auto results = strcpp::find_regex(log, regex_string);  \n  // [\"Speed : 366\", \"Speed : 378\", \"Speed : 400\"]\n\n  std::string file_path = \"/home/pranav/dev/FILE_SomeStringOfInterest_EVENT.bash\";\n  results = strcpp::find_regex(file_path, \".*FILE_(\\\\w+)_EVENT\\\\.bash.*\");\n  // results: [\"/home/pranav/dev/FILE_SomeStringOfInterest_EVENT.bash\", \"SomeStringOfInterest\"]\n}\n```\n\n## strcpp::replace\n\n```cpp\n{\n  std::string input = \"This is a test string.\";\n  std::cout \u003c\u003c strcpp::replace(input, \"a test\", \"an example\");  // \"This is an example string.\"\n  std::cout \u003c\u003c std::endl \u003c\u003c\n    strcpp::replace(input, \"test\", \"\") \u003c\u003c std::endl;            // \"This is a string\"\n\n  input = \"This is a a test string\";                            // replace the first occurrence of the letter 'a'\n  std::cout \u003c\u003c strcpp::replace(input, \"a\", \"\", 1) \u003c\u003c \"\\n\";      // \"This is a test string\"\n\n  input = \"Peter Piper picked a peck of pickled peppers.\";                            \n  std::cout \u003c\u003c strcpp::replace(input, \"p\", \"T\", 2) \u003c\u003c \"\\n\";     // \"Peter PiTer Ticked a peck of pickled peppers.\"\n\n  input = \"Peter Piper picked a peck of pickled peppers.\";\n  std::cout \u003c\u003c strcpp::replace(input, \"P\", \"T\", 2) \u003c\u003c \"\\n\";     // \"Teter Tiper picked a peck of pickled peppers.\"\n}\n```\n\n## strcpp::translate\n\n```cpp\n{\n  std::string input = \"1X444 2X3AB *^$RB (F(QP.\";                          // coded input message\n  std::map\u003cstd::string, std::string\u003e translation_table = {\n    { \"1X444\", \"Appetite\"},\n    { \"2X3AB\", \"comes\" },\n    { \"*^$RB\", \"with\" }, \n    { \"(F(QP\", \"eating\" }\n  };\n  std::string translated = strcpp::translate(input, translation_table);\n  std::cout \u003c\u003c translated \u003c\u003c std::endl;                                    // \"Appetite comes with eating.\"\n}\n```\n\n## strcpp::trim\n\n```cpp\n{\n  std::string input = \"   Hello World!   \";\n  std::cout \u003c\u003c strcpp::trim(input) \u003c\u003c std::endl;    // \"Hello World!\"\n  std::cout \u003c\u003c strcpp::ltrim(input) \u003c\u003c std::endl;   // \"Hello World!   \"\n  std::cout \u003c\u003c strcpp::rtrim(input) \u003c\u003c std::endl;   // \"   Hello World!\"\n}\n```\n\n## strcpp::format\n\n```cpp\n{\n  std::string output = strcpp::format(\"Roses are {0}, Violets are {1}, Sugar is {2}, And so are {3}!\",\n                                      { \"red\", \"blue\", \"sweet\", \"you\" });\n  std::cout \u003c\u003c output \u003c\u003c std::endl; // \"Roses are red, Violets are blue, Sugar is sweet, And so are you!\"\n\n  std::cout \u003c\u003c strcpp::format(\"{0}!... {0}!\", {\"Hodor\"}) \u003c\u003c std::endl; // \"Hodor!... Hodor!\"\n}\n```\n\n## strcpp::upper\n\n```cpp\n{\n  std::string input = \"this is some lowercase string\";\n  std::cout \u003c\u003c strcpp::upper(input) \u003c\u003c std::endl;               // \"THIS IS SOME LOWERCASE STRING\"\n}\n```\n\n## strcpp::lower\n\n```cpp\n{\n  std::string input = \"ACCIDENTALLY ENABLED CAPS LOCK!!!\";\n  std::cout \u003c\u003c strcpp::lower(input) \u003c\u003c std::endl;               // \"accidentally enabled caps lock!!!\"\n}\n```\n\n## LICENSE\n\nCopyright (c) 2017 Pranav Srinivas Kumar \u003cpranav.srinivas.kumar@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-ranav%2Fstrcpp.old","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-ranav%2Fstrcpp.old","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-ranav%2Fstrcpp.old/lists"}