{"id":15728882,"url":"https://github.com/chantsune/py_string","last_synced_at":"2025-08-07T21:14:55.964Z","repository":{"id":52090261,"uuid":"145115697","full_name":"ChanTsune/py_string","owner":"ChanTsune","description":"A library that provides methods equivalent to Python 3's str class in C ++","archived":false,"fork":false,"pushed_at":"2021-05-06T11:58:11.000Z","size":237,"stargazers_count":12,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T23:32:30.075Z","etag":null,"topics":["c-plus-plus","cpp","python","string"],"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/ChanTsune.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["ChanTsune"]}},"created_at":"2018-08-17T12:04:57.000Z","updated_at":"2022-03-28T05:17:44.000Z","dependencies_parsed_at":"2022-09-07T04:23:57.596Z","dependency_job_id":null,"html_url":"https://github.com/ChanTsune/py_string","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanTsune%2Fpy_string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanTsune%2Fpy_string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanTsune%2Fpy_string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChanTsune%2Fpy_string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChanTsune","download_url":"https://codeload.github.com/ChanTsune/py_string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253924597,"owners_count":21985142,"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","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":["c-plus-plus","cpp","python","string"],"created_at":"2024-10-03T23:07:18.275Z","updated_at":"2025-05-13T10:40:05.830Z","avatar_url":"https://github.com/ChanTsune.png","language":"C++","readme":"# py_string\n\n![CI](https://github.com/ChanTsune/py_string/workflows/CI/badge.svg)\n\nA library that provides methods equivalent to Python 3's str class in C ++  \nA class that reproduced the Python str class\n\n## Installation\n\nSince this is a single header library, it is easy to use by include only.\n\n## How to use\n\nSince it inherits std::string, it can be handled like std::string. Think that you can use python's str type method with std::string.\n\n```cpp\n#include \"py_string.hpp\"\n```\n\n### multiplication\n\n```cpp\npy::string str = \"hello world!\";\n\nstd::cout \u003c\u003c str * 2 \u003c\u003c std::endl;\n//hello world!hello world!\n```\n\n### formatting for title style\n\n```cpp\nstd::cout \u003c\u003c str.title() \u003c\u003c std::endl;\n//Hello World!\n```\n\n### splitting\n\n```cpp\npy::string str2 = \"12,3,4-2,2,3\";\nstd::deque\u003cpy::string\u003e slist; //std::vector is also acceptable\n\nstr2.split(slist, \",\");\n\nfor (auto \u0026\u0026s : slist)\n{\n    std::cout \u003c\u003c s \u003c\u003c std::endl;\n}\n//12\n//3\n//4-2\n//2\n//3\n```\n\n### formatting\n\n```cpp\npy::string str3 = \"{0} format string{1}\";\nstd::cout \u003c\u003c str3.format(\"let's\", \"!\") \u003c\u003c std::endl;\n//let's format string!\npy::string str4 = \"{}{}{}\";\nstd::cout \u003c\u003c str4.format(\"1\", 2, \"3\") \u003c\u003c std::endl;\n//123\n\npy::string str = \"{0},{1},{0}\";\nstd::cout \u003c\u003c str.format(\"apple\", \"banana\") \u003c\u003c std::endl;\n//apple,banana,apple\n\n```\n\n### string slicing\n\n```cpp\npy::string str5 = \"0123456789\";\nstd::cout \u003c\u003c str5[{0,5}] \u003c\u003c std::endl;\n//01234\nstd::cout \u003c\u003c str5[{py::nullopt, py::nullopt, -1}] \u003c\u003c std::end;\n//9876543210\n```\n\n### reverse order access\n\n```cpp\nstd::cout \u003c\u003c str5[-1] \u003c\u003c std::endl;\n//9\nstd::cout \u003c\u003c str5[-3] \u003c\u003c std::endl;\n//7\n```\n\nFor more detailed usage of this library, please refer to example.cpp.\n\nThe behavior of each method is almost the same as that of python's str type.\nPlease see python's official support for details.\n\nhttps://docs.python.org/3/library/stdtypes.html#string-methods  \n","funding_links":["https://github.com/sponsors/ChanTsune"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchantsune%2Fpy_string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchantsune%2Fpy_string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchantsune%2Fpy_string/lists"}