{"id":16646673,"url":"https://github.com/alexdelorenzo/strs","last_synced_at":"2025-04-09T16:06:08.255Z","repository":{"id":57471919,"uuid":"427565761","full_name":"alexdelorenzo/strs","owner":"alexdelorenzo","description":"🧵  Easy string tools for the shell","archived":false,"fork":false,"pushed_at":"2024-03-09T01:25:07.000Z","size":182,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:06:02.545Z","etag":null,"topics":["bash","shell","shell-script","string","string-algorithms","string-manipulation","strings","strings-python"],"latest_commit_sha":null,"homepage":"https://alexdelorenzo.dev","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexdelorenzo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["alexdelorenzo"]}},"created_at":"2021-11-13T04:13:06.000Z","updated_at":"2024-12-23T09:34:57.000Z","dependencies_parsed_at":"2024-02-22T08:29:53.232Z","dependency_job_id":"d62a9de9-d371-45b2-8a34-c0f23c49531f","html_url":"https://github.com/alexdelorenzo/strs","commit_stats":{"total_commits":234,"total_committers":2,"mean_commits":117.0,"dds":"0.10683760683760679","last_synced_commit":"429c71fe698dc4818969605988c9c862e35ae531"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdelorenzo%2Fstrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdelorenzo%2Fstrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdelorenzo%2Fstrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdelorenzo%2Fstrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexdelorenzo","download_url":"https://codeload.github.com/alexdelorenzo/strs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065289,"owners_count":21041871,"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":["bash","shell","shell-script","string","string-algorithms","string-manipulation","strings","strings-python"],"created_at":"2024-10-12T08:42:46.644Z","updated_at":"2025-04-09T16:06:08.231Z","avatar_url":"https://github.com/alexdelorenzo.png","language":"Python","funding_links":["https://github.com/sponsors/alexdelorenzo"],"categories":[],"sub_categories":[],"readme":"# Easy string tools for the shell\n\n`strs` has more than 50 tools that make working with [strings](https://en.wikipedia.org/wiki/String_(computer_science)) in the [shell](https://linuxcommand.org/lc3_lts0010.php) easier. \n\n`strs` brings common string [convenience methods](https://wiki.c2.com/?ConvenienceMethods) to shells like [Bash](https://www.gnu.org/software/bash/), because [string manipulation](https://en.wikichip.org/wiki/string_manipulation) in shells can be [hard](https://shellmagic.xyz/#string-manipulation).\n\n```bash\n$ str capitalize \"hey there! :fire:\" | str to-emoji\nHey there! 🔥\n\n$ str repeat 5 ⭐ | str join 🌙\n⭐ 🌙 ⭐ 🌙 ⭐ 🌙 ⭐ 🌙 ⭐\n```\n\n\n## Table of Contents\n* [Commands](#commands)\n* [Usage](#usage)\n  * [Practical example](#practical-example)\n  * [String manipulation in the shell](#string-manipulation-in-the-shell)\n  * [String manipulation tools](#string-manipulation-tools)\n  * [More string tools](#more-string-tools)\n  * [String validation tools](#string-validation-tools)\n* [Installation](#installation)\n  * [Prerequisites](#prerequisites)\n  * [PyPI](#pypi)\n\n\n## Commands\n\u003ctable\u003e\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#capitalization\"\u003e\u003ccode\u003ecapitalize\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#casefold\"\u003e\u003ccode\u003ecasefold\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#center\"\u003e\u003ccode\u003ecenter\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#get-columns\"\u003e\u003ccode\u003ecol\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#count\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#contains\"\u003e\u003ccode\u003econtains\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#ends-with\"\u003e\u003ccode\u003eendswith\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#find\"\u003e\u003ccode\u003efind\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#emojis\"\u003e\u003ccode\u003ehas-emoji\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#index\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#is-alphanumeric\"\u003e\u003ccode\u003eisalnum\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-alphabetic\"\u003e\u003ccode\u003eisalpha\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-ascii\"\u003e\u003ccode\u003eisascii\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-decimal\"\u003e\u003ccode\u003eisdecimal\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-digit\"\u003e\u003ccode\u003eisdigit\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#is-valid-python-identifier\"\u003e\u003ccode\u003eisidentifier\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-lower-case\"\u003e\u003ccode\u003eislower\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-numeric\"\u003e\u003ccode\u003eisnumeric\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-printable\"\u003e\u003ccode\u003eisprintable\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-space-character\"\u003e\u003ccode\u003eisspace\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#is-title-case\"\u003e\u003ccode\u003eistitle\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#is-upper-case\"\u003e\u003ccode\u003eisupper\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#join\"\u003e\u003ccode\u003ejoin\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#string-length\"\u003e\u003ccode\u003elength\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#capitalization\"\u003e\u003ccode\u003elower\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#left-justify\"\u003e\u003ccode\u003eljust\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#left-strip\"\u003e\u003ccode\u003elstrip\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#return-nth-lines\"\u003e\u003ccode\u003enth\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#partition\"\u003e\u003ccode\u003epartition\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#replace\"\u003e\u003ccode\u003ereplace\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#replace\"\u003e\u003ccode\u003ereplace-first\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#repeat\"\u003e\u003ccode\u003erepeat\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#right-find\"\u003e\u003ccode\u003erfind\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#right-index\"\u003e\u003ccode\u003erindex\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#right-partition\"\u003e\u003ccode\u003erpartion\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n \n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#right-split\"\u003e\u003ccode\u003ersplit\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#right-strip\"\u003e\u003ccode\u003erstrip\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#right-justify\"\u003e\u003ccode\u003erjust\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#capitalization\"\u003e\u003ccode\u003eupper\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#split\"\u003e\u003ccode\u003esplit\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#strip\"\u003e\u003ccode\u003estrip\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#type-like-this\"\u003e\u003ccode\u003esbob\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#starts-with\"\u003e\u003ccode\u003estartswith\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#substring\"\u003e\u003ccode\u003esubstring\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#slice\"\u003e\u003ccode\u003eslice\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n   \u003ctd\u003e\u003ca href=\"#to-title-case\"\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#to-ascii\"\u003e\u003ccode\u003eto-ascii\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#readme\"\u003e\u003ccode\u003eto-emoji\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#from-emoji\"\u003e\u003ccode\u003efrom-emoji\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n   \u003ctd\u003e\u003ca href=\"#zero-fill\"\u003e\u003ccode\u003ezerofill\u003c/code\u003e\u003c/a\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n# Usage\n## Practical example\nIf you're on [Debian](https://www.debian.org/), you can use `strs` to take your [apt sources](https://wiki.debian.org/SourcesList) from Debian [`testing`](https://wiki.debian.org/DebianTesting), point them to Debian [`stable`](https://wiki.debian.org/DebianStable) on the fly, and then send them to a `stable` machine:\n```bash\n$ str replace testing stable \u003c sources.list | ssh host \"cat \u003e /etc/apt/sources.list\"\n```\n\nTo do the same with [`sed`](https://en.wikipedia.org/wiki/Sed), you'd need to know [`sed`'s regex syntax](https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html), if your `sed` [comes with the `-i` feature flag](https://unix.stackexchange.com/questions/401905/bsd-sed-vs-gnu-sed-and-i), and [if it's GNU `sed` or BSD `sed`](https://riptutorial.com/sed/topic/9436/bsd-macos-sed-vs--gnu-sed-vs--the-posix-sed-specification).\n\n`strs`, on the other hand, has a uniform interface and set of features across platforms, shells and operating systems, including Windows.\n\n## String manipulation in the shell\n`strs` has string tools that are similar to [those that are built into Bash](https://tldp.org/LDP/abs/html/string-manipulation.html), and it has commands for features that Bash doesn't have [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar) for, as well. \n\nThe following examples of Bash code only work with Bash, whereas `strs` commands will work if you're using Bash, [zsh](https://www.zsh.org/), PowerShell or something else.\n\n### String length\n#### Bash\n```bash\nstring='This is an example.'\n\n$ echo \"${#string}\"\n19\n```\n\n#### `strs`\n```bash\n$ str length \"$string\"\n19\n```\n\nOr, using pipes:\n```bash\n$ echo $string | str length\n19\n```\n\n### Strip\n#### Bash\n```bash\nfront='This'\nend='example.'\n\n$ echo \"${string#$front}\"  # from front\n is an example.\n\n$ echo \"${string%$end}\"  # from end\nThis is an\n```\n\n##### `strs`\n```bash\n$ str lstrip $front \"$string\"\n is an example.\n\n$ str rstrip $end \"$string\"\nThis is an\n\n$ str strip $front$end \"$string\"\n is an\n```\n\nOr, using pipes:\n```bash\n$ echo $string | str lstrip $front\n is an example.\n\n$ echo $string | str rstrip $end\nThis is an\n\n$ echo $string | str strip $front$end\n is an\n```\n\n### Capitalization\n#### Bash\n```bash\n$ echo \"${string^}\"  # capitalize first char\nThis is an example.\n\n$ echo \"${string^^}\"  # capitalize all\nTHIS IS AN EXAMPLE.\n\n$ echo \"${string,,}\"  # lower all\nthis is an example.\n```\n\n#### `strs`\n```bash\n$ str capitalize \"$string\"\nThis is an example.\n\n$ str upper \"$string\"\nTHIS IS AN EXAMPLE.\n\n$ str lower \"$string\"\nthis is an example.\n```\n\nOr:\n```bash\n$ echo $string | str capitalize\nThis is an example.\n\n$ echo $string | str upper\nTHIS IS AN EXAMPLE.\n\n$ echo $string | str lower\nthis is an example.\n```\n\n### Replace\n#### Bash\n```bash\nold='an'\nnew='a'\n\n$ echo \"${string//$old/$new}\"  # replace all\nThis is a example.\n\n$ echo \"${string/$old/$new}\"  # replace first\nThis is a example.\n```\n\n#### `strs`\n```bash\n$ str replace $old $new \"$string\"\nThis is a example.\n\n$ str replace $old $new \"$string\" --count 1\nThis is a example.\n\n$ str replace-first $old $new \"$string\"\nThis is a example.\n```\n\nOr:\n```bash\n$ echo $string | str replace $old $new\n$ echo $string | str replace $old $new --count 1\n$ echo $string | str replace-first $old $new\n```\n\n## String manipulation tools\n`strs` has string manipulation commands that don't have syntactic sugar in Bash.\n\n### [Casefold](https://docs.python.org/3/library/stdtypes.html#str.casefold)\n```bash\nstring='This is an example.'\n\n$ str casefold \"$string\"\nthis is an example.\n```\n\n```bash\n$ echo $string | str casefold\nthis is an example.\n```\n\n### Center\n```bash\nwidth=40\n\n$ str center $width \"$string\"\n          This is an example.           \n```\n\n```bash\n$ echo $string | str center $width\n          This is an example.           \n```\n\n### Count\n```bash\ncountChar='e'\n\n$ str count $countChar \"$string\"\n2\n```\n\n```bash\n$ echo $string | str count $countChar\n2\n```\n\n### Find\n```bash\nfind='e'\n\n$ str find $find \"$string\"\n11\n```\n\n```bash\n$ echo $string | str find $find\n11\n```\n\n### Index\n```bash\n$ str index $find \"$string\"\n11\n```\n\n```bash\n$ echo $string | str index $find\n11\n```\n\n### Join\n```bash\non='_'\n\n$ str join $on $string\nThis_is_an_example.\n```\n\n```bash\n$ str split ' ' \"$string\" | str join $on\nThis_is_an_example.\n```\n\n### Partition\n```bash\npart=' '\n\n$ str partition \"$part\" \"$string\"\nThis\n\nis an example.\n```\n\n```bash\n$ echo $string | str partition \"$part\"\n[...]\n```\n\n### Split\n```bash\nsplit=' '\n\n$ str split \"$split\" \"$string\"\nThis\nis\nan\nexample.\n```\n\n```bash\n$ echo $string | str split \"$split\"\n[...]\n```\n\n### Strip\n```bash\nstrip='.'\n\n$ str strip $strip \"$string\"\nThis is an example\n```\n\n```bash\n$ echo $string | str strip $strip\nThis is an example\n```\n\n### Swap case\n```bash\n$ str swapcase \"$string\"\ntHIS IS AN EXAMPLE.\n```\n\n```bash\n$ echo $string | str swapcase\ntHIS IS AN EXAMPLE.\n```\n\n### To title case\n```bash\n$ str title \"$string\"\nThis Is An Example.\n```\n\n```bash\n$ echo $string | str title\nThis Is An Example.\n```\n\n### Zero fill\n```bash\n$ str zfill $width \"$string\"\n000000000000000000000This is an example.\n```\n\n```bash\n$ echo $string | str zfill $width\n000000000000000000000This is an example.\n```\n\n### Repeat\n```bash\n$ str repeat 3 \"$string\"\nThis is an example.\nThis is an example.\nThis is an example.\n```\n\n```bash\n$ echo $string | str repeat 3\n[...]\n```\n\n### Left justify\n```bash\n$ str ljust $width \"$string\" --fillchar '*'\nThis is an example.*********************\n```\n\n```bash\n$ echo $string | str ljust $width --fillchar '*'\nThis is an example.*********************\n```\n\n### Left strip\n```bash\n$ str lstrip T \"$string\"\nhis is an example.\n```\n\n```bash\n$ echo $string | str lstrip T\nhis is an example. \n```\n\n### Right find\n```bash\n$ str rfind $find \"$string\"\n17\n```\n\n```bash\n$ echo $string | str rfind $find\n17\n```\n\n### Right index\n```bash\n$ str rindex $find \"$string\"\n17\n```\n\n```bash\n$ echo $string | str rindex $find\n17\n```\n\n### Right justify\n```bash\n$ str rjust $width \"$string\"\n                     This is an example.\n```\n\n```bash\n$ echo $string | str rjust $width\n                     This is an example.\n```\n\n### Right strip\n```bash\nremove='.'\n\n$ str rstrip $remove \"$string\"\nThis is an example\n```\n\n```bash\n$ echo $string | str rstrip $remove\nThis is an example\n```\n\n### Right partition\n```bash\n$ str rpartition \"$part\" \"$string\"\nThis is an\n\nexample.\n```\n\n```bash\n$ echo $string | str rpartition \"$part\"\n[...]\n```\n\n### Right split\n```bash\n$ str rsplit \"$split\" \"$string\"\nThis\nis\nan\nexample.\n```\n\n```bash\n$ echo $string | str rsplit \"$split\"\n[...]\n```\n\n## More string tools\n`strs` has tools that deal with UTF-8, ASCII and emojis, and it has tools that aren't found in Python or common shells.\n\n### To ASCII\n```bash\n$ str to-ascii \"It is 20° Celsius outside.\"\nIt is 20deg Celsius outside.\n```\n\n```bash\n$ str to-ascii \"Ǎ Ě Ǐ Ǒ Ǔ Č Ď Ǧ Ȟ ǰ Ǩ Ľ Ň Ř Š Ť Ž\"\nA E I O U C D G H j K L N R S T Z\n```\n\n### Substring\n```bash\n$ str substring 3 \"Hey there! 🔥\"\nHey\n```\n\nYou can use negative indices like you can in Python:\n```bash\n$ str substring -3 \"Hey there! 🔥\" --start 4\nthere\n```\n\n### Slice\nYou can use Python's slice syntax directly, too.\n```bash\n$ str slice 4:-3 \"Hey there! 🔥\"\nthere\n```\n\n### Contains\n```bash\n$ str contains 🔥 \"Hey there! 🔥\"; echo $?\n0\n```\n\n### Emojis\n```bash\n$ str has-emoji \"Hey there! 🔥\"; echo $?\n0\n```\n\n```bash\n$ str from-emoji \"Hey there! 🔥\"\nHey there! :fire:\n```\n\n### Get columns\n```bash\n$ str col 2 'hello world'\nworld\n```\n\n```bash\n$ echo -e 'hello\\tworld' | str col 2\nworld\n```\n\n### Return nth lines\n```bash\n$ sudo dmesg | str nth 50\n[73627.811739] Filesystems sync: 0.02 seconds\n```\n\n### [tYpE lIkE tHiS](https://www.dailydot.com/unclick/mocking-spongebob-meme/)\n```bash\n$ str sbob \"squidward likes krabby patties\"\nsQuIdWaRd LiKeS kRaBbY pAtTiEs\n```\n\n## String validation tools\n`strs` also brings [Python's string validation methods](https://docs.python.org/3/library/stdtypes.html#str) to the shell.\n\nHere's an example of how you'd use them in a [conditional statement](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs), followed by examples of other validation tools:\n```bash\nstring='This is an example.'\n\n\nif str startswith T \"$string\" \u0026\u0026 str endswith . \"$string\"; then\n  printf \"Starts with T and ends with .\\n\"\n\nelif str contains example \"$string\"; then\n  printf \"Contains 'example'\\n\"\n\nelif !str isalnum \"$string\"; then\n  printf \"Isn't alphanumeric\\n\"\n\nfi\n```\n\n### Starts with\n```bash\n$ str startswith T \"$string\"; echo $?\n0\n```\n\n```bash\n$ echo $string | str startswith T; echo $?\n0\n```\n\n### Ends with\n```bash\n$ str endswith . \"$string\"; echo $?\n0\n```\n\n```bash\n$ echo $string | str endswith .; echo $?\n0\n```\n\n### Is alphanumeric\n```bash\n$ str isalnum \"$string\"; echo $?\n0\n```\n\n```bash\n$ echo $string | str isalnum; echo $?\n0\n```\n\n### Is alphabetic\n```bash\n$ str isalpha \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isalpha; echo $?\n1\n```\n\n### Is ASCII\n```bash\n$ str isascii \"$string\"; echo $?\n0\n```\n\n```bash\n$ echo $string | str isascii; echo $?\n0\n```\n\n### Is decimal\n```bash\n$ str isdecimal \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isdecimal; echo $?\n1\n```\n\n### Is digit\n```bash\n$ str isdigit \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isdigit; echo $?\n1\n```\n\n### Is valid Python identifier\n```bash\n$ str isidentifier \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isidentifier; echo $?\n1\n```\n\n### Is lower case\n```bash\n$ str islower \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str islower; echo $?\n1\n```\n\n### Is numeric\n```bash\n$ str isnumeric \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isnumeric; echo $?\n1\n```\n\n### Is printable\n```bash\n$ str isprintable \"$string\"; echo $?\n0\n```\n\n```bash\n$ echo $string | str isprintable; echo $?\n0\n```\n\n### Is space character\n```bash\n$ str isspace \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isspace; echo $?\n1\n```\n\n### Is title case\n```bash\n$ str istitle \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str istitle; echo $?\n1\n```\n\n### Is upper case\n```bash\n$ str isupper \"$string\"; echo $?\n1\n```\n\n```bash\n$ echo $string | str isupper; echo $?\n1\n```\n\n# Installation\n## Prerequisites\n - A [Unix shell](https://en.wikipedia.org/wiki/Unix_shell) like Bash, or PowerShell or Command Prompt on Windows\n - Python 3.10+\n - `requirements.txt`\n\n## PyPI\n```bash\npython3 -m pip install strs\n```\nYou can view the [`strs` package on PyPI](https://pypi.org/project/strs/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdelorenzo%2Fstrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexdelorenzo%2Fstrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdelorenzo%2Fstrs/lists"}