{"id":13761124,"url":"https://github.com/Yonaba/Allen","last_synced_at":"2025-05-10T12:31:01.333Z","repository":{"id":4059992,"uuid":"5163451","full_name":"Yonaba/Allen","owner":"Yonaba","description":"An utility library to manipulate strings in Lua","archived":false,"fork":false,"pushed_at":"2013-09-20T15:51:03.000Z","size":663,"stargazers_count":47,"open_issues_count":2,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-03T13:06:04.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://yonaba.github.com/Allen","language":"Lua","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/Yonaba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-24T09:12:35.000Z","updated_at":"2024-03-13T15:27:31.000Z","dependencies_parsed_at":"2022-09-08T20:00:10.605Z","dependency_job_id":null,"html_url":"https://github.com/Yonaba/Allen","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yonaba%2FAllen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yonaba%2FAllen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yonaba%2FAllen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yonaba%2FAllen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yonaba","download_url":"https://codeload.github.com/Yonaba/Allen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224957951,"owners_count":17398494,"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":[],"created_at":"2024-08-03T13:01:39.442Z","updated_at":"2024-11-16T18:32:05.420Z","avatar_url":"https://github.com/Yonaba.png","language":"Lua","funding_links":[],"categories":["Lua","Resources"],"sub_categories":["Utilities"],"readme":"﻿__Allen__ is a Lua library which provides a set of utilities and helpers for strings operations.\nIn a nutshell, __Allen__ is to strings what [Moses][] is to tables.\n__Allen__ can be considered as an extension of the built-in Lua string library.\u003cbr/\u003e\n__Allen__'s API was heavily inspired by the Javascript library [Underscore.string][].\n\n##Installation##\nPut the file [Allen.lua][] inside your project folder and call it using *require* command.\nIt will return a table containing a set of functions.\n\n##Usage example##\n\n```lua\nlocal lyrics = 'hey I just met you\\nand this is crazy\\nbut here is my number\\nso call me maybe'\nlyrics = _.lines(lyrics)\nfor i,line in ipairs(lyrics) do \n  line = _.capitalizeFirst(line) \nend\n-- =\u003e { 'Hey I just met you',\n--      'And this is crazy',\n--      'But here is my number',\n--      'So call me maybe'}\n```\n\n##Allen and the built-in string library##\n__Allen__ provides a very handy function named *_.import*, which links Lua's native string library with __Allen__'s functions.\n\n```lua\n_.import()\nprint(string.capitalize('hello'))\nprint(('Hello'):splice(2,2,'r'))\n```\n\n##About Lua Operators##\nOnce __Allen__ is called inside your projet,it enables the use of arithmetic operators on strings by default.\u003cbr/\u003e\nCompatible operators are : __+,*,/,%,^,-.__\n\n* Addition operator (+) : concatenates two strings\n* Unary operator (-) : reverses a string\n* Multiplication operator (*) : repeats a string\n* Power operator (^) : also repeats a string\n* Division operator (/) : used for chopping strings (dividing it in subsets strings)\n* Modulo operator (%) : returns the remainder subset string after a chopping process.\n\n##Strings Indexing##\nUsing __Allen__, strings can be indexed, like regular Lua tables.\n\n```lua\nfor i = 1,5 do \n  print(('Accessing %s[%d] :'):format('Hello',i),('Hello')[i]) \nend\n-- =\u003e Accessing Hello[1] :\tH\n-- =\u003e Accessing Hello[2] :\te\n-- =\u003e Accessing Hello[3] :\tl\n-- =\u003e Accessing Hello[4] :\tl\n-- =\u003e Accessing Hello[5] :\to\n```\n\n##Strings as functions##\nOnce __Allen__ is loaded inside a project, strings can be called as functions.\n\n```lua \nlocal s = 'Hello'\nprint(s()) --\u003e 'Hello'\n```\n\t\nPassing a positive number \u003ctt\u003ei\u003c/tt\u003e as the first argument will return the character at the corresponding index\n\n```lua\nlocal s = 'Hello'\nprint(s(2)) --\u003e 'e'\n```\n\t\nPassing a number \u003ctt\u003ej\u003c/tt\u003e as a second argument will return the substring between \u003ctt\u003ei\u003c/tt\u003e and \u003ctt\u003ej\u003c/tt\u003e\n\n```lua\nlocal s = 'Hello'\nprint(s(2,4)) --\u003e 'ell'\n```\n\t\nPassing a character as a second argument will replace the character at index \u003ctt\u003ei\u003c/tt\u003e\n\n```lua\nlocal s = 'Helo'\nprint(s(3,'r')) --\u003e 'Hero'\n```\n\nSee [Allen_StringOp_Snippets.lua][] for more details.\n\t\n##API Overview##\n__Allen__ offers a lot of functions, iterators to operate on strings.\u003cbr/\u003e\nA fully complete documentation, with usage examples can be found here : [Documentation][]\u003cbr/\u003e\nSome usage examples can be found here : [Allen_Lib_Snippets.lua][] and [Allen_StringOp_Snippets.lua][]\n\n##Credits and Thanks##\n[Esa-Matti Suuronen][] and [Edward Tsech][], for the amazing [Underscore.string][]\n\n##License##\nThis work is under [MIT-LICENSE][]\u003cbr/\u003e\nCopyright (c) 2012 Roland Yonaba\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[Underscore.string]: https://github.com/epeli/underscore.string\n[Moses]: https://github.com/Yonaba/Moses\n[Allen.lua]: https://github.com/Yonaba/Allen/blob/master/Lib/Allen.lua\n[Documentation]: https://github.com/Yonaba/Allen/blob/master/Documentation\n[Allen_Lib_Snippets.lua]: https://github.com/Yonaba/Allen/blob/master/Allen_Lib_Snippets.lua\n[Allen_StringOp_Snippets.lua]: https://github.com/Yonaba/Allen/blob/master/Allen_StringOp_Snippets.lua\n[Esa-Matti Suuronen]: https://github.com/epeli\n[Edward Tsech]: https://github.com/edtsech\n[MIT-LICENSE]: http://www.opensource.org/licenses/mit-license.php\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Yonaba/allen/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYonaba%2FAllen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYonaba%2FAllen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYonaba%2FAllen/lists"}