{"id":18391070,"url":"https://github.com/kasperosterbye/stringutilities","last_synced_at":"2025-10-26T19:44:56.411Z","repository":{"id":108794229,"uuid":"238162217","full_name":"kasperosterbye/StringUtilities","owner":"kasperosterbye","description":"String slices and string builder for pharo","archived":false,"fork":false,"pushed_at":"2020-05-15T05:55:24.000Z","size":61,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T08:59:56.071Z","etag":null,"topics":["pharo"],"latest_commit_sha":null,"homepage":"","language":"Smalltalk","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/kasperosterbye.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":"2020-02-04T08:55:11.000Z","updated_at":"2020-05-15T05:55:26.000Z","dependencies_parsed_at":"2023-04-17T01:05:12.253Z","dependency_job_id":null,"html_url":"https://github.com/kasperosterbye/StringUtilities","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasperosterbye%2FStringUtilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasperosterbye%2FStringUtilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasperosterbye%2FStringUtilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasperosterbye%2FStringUtilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kasperosterbye","download_url":"https://codeload.github.com/kasperosterbye/StringUtilities/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543861,"owners_count":21121838,"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":["pharo"],"created_at":"2024-11-06T01:50:30.638Z","updated_at":"2025-10-26T19:44:51.369Z","avatar_url":"https://github.com/kasperosterbye.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StringSlice\n\n\nA string slice a substring obtained by a `start` and an `end` index into an existing string. It is thus possible to get substrings without copying the bytes of the original string - at least for a large number of operations.\n\nThe package adds one extra method to class String: the `sliceFrom: a to: b`. \n\n```smalltalk\nslice := 'aaabbbccc' sliceFrom: 4 to: 6.\rslice = 'bbb' \u003e\u003e\u003e true.\rslice size \u003e\u003e\u003e 3.\r(slice at: 2) \u003e\u003e\u003e $b.\rslice hash = 'bbb' hash \u003e\u003e\u003e true.\n```\n\n**This library also contains a [StringBuilder](StringBuilder.md)**\n\n\n## Metacello call\n\n\n```smalltalk\nMetacello new\n   baseline: 'StringUtilities';\n   repository: 'github://kasperosterbye/StringUtilities';\n   load.\n```\n\n## Implementation notes\n\n### Imutable\nStringSlice does not allow changes to the original string. \n\n* Some mutatation operations will give an error - `at:put:` is not allowed.\n* Other mutation operations already have copy semantics for String, for example asUppercase. These copying methods do not return a slice, but a String.\n\n### Complete\nI have tried my best to make sure slices respond to the same protocol as String.\n\nWhile the Metacello expression above do not load the tests, I have ported all the non-destructive tests from string to make sure all string methods work on slices. Any missing issue - please raise them. \n\n### Effecient \nA large number of methods return slices if used on a slice. For example:\n\n* The substrings: method return slices if the original is a slice.\n* Regular expression matching returns slices if the original is a slice.\n\n```smalltalk\nslice := 'aaa bbb ccc' sliceFrom: 1 to: 11.\r\r((slice substrings: ' ') collect: [:s | s class]) \u003e\u003e\u003e\r    {StringSlice. StringSlice. StringSlice}.\n    \n'(a+|c+)' asRegex  matchesIn: slice. \"returns slices\"\n```\n\nThe slice has three instance variables, the original string, start and end. Making them is therefore rather fast. In fact my timings show it is faster to make a zero length slice than a zero length string copy. There are some timing methods in the StringSlice class side. Perhaps yours computer is different than mine.\n\n### Comments onString\nWhile I have been testing Slice, I have come across a number of issues with the class String. They are summarized in [StringIssues](StringIssues.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasperosterbye%2Fstringutilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkasperosterbye%2Fstringutilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasperosterbye%2Fstringutilities/lists"}