From 397c518833d9ed19614237ac89e4251515d9e3dd Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 19 Sep 2019 10:56:28 +0300 Subject: [PATCH] docs: update --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 6272423..d3ddb29 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,47 @@ A collection of pure POSIX `sh` alternatives to external processes +* [STRINGS](#strings) + * [Strip pattern from start of string](#strip-pattern-from-start-of-string) + * [Strip pattern from end of string](#strip-pattern-from-end-of-string) + + + +# STRINGS + +## Strip pattern from start of string + +**Example Function:** + +```sh +lstrip() { + # Usage: lstrip "string" "pattern" + printf '%s\n' "${1##$2}" +} +``` + +**Example Usage:** + +```shell +$ lstrip "The Quick Brown Fox" "The " +Quick Brown Fox +``` + +## Strip pattern from end of string + +**Example Function:** + +```sh +rstrip() { + # Usage: rstrip "string" "pattern" + printf '%s\n' "${1%%$2}" +} +``` + +**Example Usage:** + +```shell +$ rstrip "The Quick Brown Fox" " Fox" +The Quick Brown +```