{"id":21361067,"url":"https://github.com/geeksloth/get-value-by-separator","last_synced_at":"2026-05-21T04:07:02.557Z","repository":{"id":264021908,"uuid":"892107915","full_name":"geeksloth/get-value-by-separator","owner":"geeksloth","description":"Extracts a substring from a given string based on a separator and an index. Works on native C language and Arduino.","archived":false,"fork":false,"pushed_at":"2024-11-21T14:52:16.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T06:43:12.087Z","etag":null,"topics":["arduino"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geeksloth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-11-21T14:22:01.000Z","updated_at":"2024-11-21T14:52:27.000Z","dependencies_parsed_at":"2024-11-21T15:46:17.633Z","dependency_job_id":null,"html_url":"https://github.com/geeksloth/get-value-by-separator","commit_stats":null,"previous_names":["geeksloth/get-value-by-delimiter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/geeksloth/get-value-by-separator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Fget-value-by-separator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Fget-value-by-separator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Fget-value-by-separator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Fget-value-by-separator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geeksloth","download_url":"https://codeload.github.com/geeksloth/get-value-by-separator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Fget-value-by-separator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33288197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T02:57:32.698Z","status":"ssl_error","status_checked_at":"2026-05-21T02:57:31.990Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["arduino"],"created_at":"2024-11-22T06:08:22.553Z","updated_at":"2026-05-21T04:07:02.540Z","avatar_url":"https://github.com/geeksloth.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# get-value-by-separator\n\nExtracts a substring from a given string based on a separator and an index.\nWorks on native C language and Arduino.\n\n# Usage\n```cpp\nString text = \"apple,banana,cherry\";\n\nString result = getValue(text, ',', 1);\n// result will be \"banana\"\n```\n\nIn this example, the function will return \"banana\" as it is the substring at index 1 when the string is split by the comma separator.\n\n# Code\nThis function searches for the nth occurrence of a separator character in the input string and returns the substring located at that position.\n```cpp\n/**\n * @brief Extracts a substring from a given string based on a separator and an index.\n *\n * This function searches for the nth occurrence of a separator character in the input string\n * and returns the substring located at that position.\n *\n * @param text The input string from which the substring will be extracted.\n * @param separator The character used to separate the substrings within the input string.\n * @param index The zero-based index of the substring to be extracted.\n * @return A substring located at the specified index, or an empty string if the index is out of bounds.\n */\nString getValue(String text, char separator, int index) {\n  int found = 0;\n  int string_index[] = {0, -1};\n  int max_index = text.length()-1;\n  for (int i = 0; i \u003c= max_index \u0026\u0026 found \u003c= index; i++) {\n    if (text.charAt(i) == separator || i == max_index){\n      found++;\n      string_index[0] = string_index[1] + 1;\n      string_index[1] = (i == max_index) ? i + 1 : i;\n    }\n  }\n  return found \u003e index ? text.substring(string_index[0], string_index[1]) : \"\";\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeksloth%2Fget-value-by-separator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeeksloth%2Fget-value-by-separator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeksloth%2Fget-value-by-separator/lists"}