{"id":19162919,"url":"https://github.com/hernanmd/stringextensions","last_synced_at":"2025-10-14T17:10:19.450Z","repository":{"id":71141426,"uuid":"113533608","full_name":"hernanmd/StringExtensions","owner":"hernanmd","description":"Add useful String extension method to Pharo String class","archived":false,"fork":false,"pushed_at":"2023-02-22T13:22:27.000Z","size":695,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-22T22:41:57.857Z","etag":null,"topics":["levenshtein","pharo","pharo-smalltalk","smalltalk","string","string-manipulation","string-matching"],"latest_commit_sha":null,"homepage":"","language":"Smalltalk","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/hernanmd.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}},"created_at":"2017-12-08T04:58:11.000Z","updated_at":"2022-03-20T21:52:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"407ac775-bdd4-4de9-a74c-000ba8d19096","html_url":"https://github.com/hernanmd/StringExtensions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hernanmd/StringExtensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernanmd%2FStringExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernanmd%2FStringExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernanmd%2FStringExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernanmd%2FStringExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hernanmd","download_url":"https://codeload.github.com/hernanmd/StringExtensions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hernanmd%2FStringExtensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020087,"owners_count":26086805,"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-10-14T02:00:06.444Z","response_time":60,"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":["levenshtein","pharo","pharo-smalltalk","smalltalk","string","string-manipulation","string-matching"],"created_at":"2024-11-09T09:13:32.866Z","updated_at":"2025-10-14T17:10:19.396Z","avatar_url":"https://github.com/hernanmd.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Table of Contents\n\n- [Description](#description)\n- [Installation](#installation)\n  - [Install from CLI](#install-from-cli)\n  - [Install from Pharo](#install-from-pharo)\n  - [Baseline Snippet](#baseline-snippet)\n- [Details](#details)\n  - [Summary](#summary)\n  - [Extraction Methods](#extraction-methods)\n  - [Conversion Methods](#conversion-methods)\n  - [Testing Methods](#testing-methods)\n- [Implementation notes](#implementation-note)\n- [License](#license)\n\n# Description\n\nAdd missing useful String extension method to Pharo String class.\n\n# Installation\n\n## Install from CLI\n\nInstall **StringExtensions** from Command-Line Interface using [Pharo Install](https://github.com/hernanmd/pi):\n\n```bash\npi install StringExtensions\n```\n\n## Install from Pharo\n\n```smalltalk\nEpMonitor disableDuring: [ \n\tMetacello new\n\t\tbaseline: 'StringExtensions';\n\t\trepository: 'github://hernanmd/StringExtensions/repository';\n\t\tload ].\n```\n\n## Baseline Snippet\n\nIf you want to add it to your Metacello Baseline, copy and paste the following expression:\n\n```smalltalk\n\t\" ... \"\n\t\tbaseline: 'StringExtensions' \n\t\twith: [ spec repository: 'github://hernanmd/StringExtensions/repository' ].\n\t\" ... \"\n```\n\n# Details\n\nTo quickly find methods provided by this package, please evaluate:\n\n```smalltalk\n(String methods select: #isExtension) select: [ : p | p package name = 'StringExtensions' ]\n```\n\n## Summary\n\n |**Method**|**Purpose**|\n | ------------- | ------------- |\n |asCondensedString|Return a copy of the receiver with leading/trailing blanks removed and white spaces condensed|\n |asFloat|Answer a \u003cFloat\u003e that represents the value of the receiver|\n |beginsWith:or:|Answer \u003ctrue\u003e if receiver's begins with firstPrefix or secondPrefix|\n |copyUpToAny:|Answer a \u003cString\u003e discarding all elements in the receiver which appear after any of of the elements in aCollection|\n |copyUpToStartParenthesis|Answer the receiver without preserving all Character's up to the first opening parenthesis|\n |findNumbers|Answer a \u003cCollection\u003e of numbers, removing other characters|\n |hammingDistanceTo:|Answer a \u003cNumber\u003e respresenting the minimum amount of substitutions to convert the receiver into aString|\n |includesBeginWith:|Answer whether aString begins like one of the receiver's sub strings elements|\n |includesEndsWith:|Answer whether aString ends like one of the receiver's sub strings elements|\n |indexesOfMotif:|Answer a \u003cCollection\u003e of indexes of a motif in a string|\n |indicesOfCharacter:|Given aCharacter contained in the receiver, answer a \u003cCollection\u003e of positions where the aCharacter is found|\n |indicesOfSubstring:|Given aCharacter contained in the receiver, answer a \u003cCollection\u003e of positions where the aCharacter is found|\n |indicesOfSubstring:mismatches:|Answer a \u003cCollection\u003e of start positions where subString is found allowing at most d mismatches|\n |indicesOfSubstringOverlaps:|Given aCharacter contained in the receiver, answer a \u003cCollection\u003e of positions where the aCharacter is found|\n |isAllBlanks|Answer \u003ctrue\u003e whether the receiver is composed entirely of space separators|\n |isAllLetters|Answer \u003ctrue\u003e whether the receiver is composed entirely of letters|\n |isNumeric|Answer whether the receiver is a Number|\n |isXML|Only answer \u003ctrue\u003e when the receiver's contents *looks like* XML, not performing any validity check|\n |isZipped|Answer \u003ctrue\u003e if receiver conforms to GZIP file format|\n |levenshteinDistanceTo:|Iterative calculation of the Levenshtein distance between two strings|\n |lowercaseFirstLetter|Answer a String made up from the receiver whose first character is lowercase|\n |shingle:|Answer an \u003cOrderedSet\u003e with contiguous sequences (shingles) of n characters|\n |shingleMax:|Answer an maximally shingled \u003cSet\u003e with contiguous sequences (shingles) of n characters|\n |shingleWords:|Word shingling|\n |withoutBlanks|Return a copy of the receiver with leading/trailing blanks removed and white spaces condensed|\n |withoutCRs|Answer the receiver without carriage returns|\n |withoutNumbers|Return a copy of the receiver with numbers removed|\n\t\n## Extraction Methods\n\n### findNumbers\n\nExtracting numbers in Strings is easily supported in Pharo:\n\n```smalltalk\n'Hola123Mundo' asInteger. \"123\"\n```\n\nHowever, consider the following:\n\n```smalltalk\n'Hola123Mundo234' asInteger. \"123\"\n```\n\nIf we want to extract all numbers in the received **String**, then we could use #findNumbers:\n\n```smalltalk\n'Hola123Mundo234'  \"an OrderedCollection('123' '234')\"\n```\n\n- On empty **String**, answer an empty **Collection**\n- Negative Integers are extracted with sign: `'Hola-10' findNumbers. \"an OrderedCollection('-10')\"`\n- Floats are not supported: `'Hola30.6' findNumbers.  \"an OrderedCollection('30' '6')\"`\n\n### withoutBlanks\n\nReturn a copy of the receiver with leading/trailing blanks removed and white spaces condensed.\n\n### withoutNumbers\n\nReject all digits from the received **String**. Examples:\n\n```smalltalk\n'3333' withoutNumbers = ''.\n\n'aaaa' withoutNumbers = 'aaaa'.\n\n'aaa1234' withoutNumbers = 'aaa'.\n\n'' withoutNumbers = ''\n```\n\n## Conversion Methods\n\n### asCondensedString\n\nReturn a copy of the receiver with leading/trailing blanks removed and white spaces condensed.\n\n### withoutCRs\n\nReturn a copy of the receiver without carriage returns.\n\n## Testing Methods\n\n### includesBeginWith:\n\nAnswer whether the parameter **String** begins like one of the receiver's sub strings elements. For example, the following expressions evaluate all to *true*:\n\n```smalltalk\n'Rose is a rose of splendor' includesBeginWith: 'rose'.\n\n'Rose is a rose of splendor' includesBeginWith: 'ROSE'.\n\n'Raise the art to resistance' includesBeginWith: 'resist'.\n\n'Danger dare to be grand' includesBeginWith: 'dar'.\n```\n\n### isAllLetters\n\nAnswer *true* whether the receiver is composed entirely of letters.\n\n### isNumeric\n\nAnswer whether the receiver is a **Number**. It uses a regular expression. \n\n### isXML\n\nCheap checking of beggining XML document, no parsing involved, just check '\u003c?xml'.\n\n### isZipped\n\nUses **GZipConstants** gzipMagic to check if the received **String** conforms to GZip file format.\n\n\n# License\n\nThis software is licensed under the MIT License.\n\nCopyright Hernán Morales, 2018-2022\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhernanmd%2Fstringextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhernanmd%2Fstringextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhernanmd%2Fstringextensions/lists"}