importpw / string

String manipluation functions for shell scripts

Home Page:https://import.pw/string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

string

String manipluation functions for shell scripts.

API

string_lower

#!/usr/bin/env import
import "string"

echo iNpUt | string_lower
# input

string_upper

#!/usr/bin/env import
import "string"

echo InPuT | string_upper
# INPUT

string_includes

#!/usr/bin/env import
import "string"

print_string_includes() {
  if string_includes "$1" "$2"; then
    echo "'$1' includes '$2'"
  else
    echo "'$1' does not include '$2'"
  fi
}

print_string_includes "hello" "el"
# 'hello' includes 'el'

print_string_includes "hello" "al"
# 'hello' does not include 'al'"

string_starts_with

#!/usr/bin/env import
import "string"

print_string_starts_with() {
  if string_starts_with "$1" "$2"; then
    echo "'$1' starts with '$2'"
  else
    echo "'$1' does not start with '$2'"
  fi
}

print_string_starts_with "hello" "hel"
# 'hello' starts with 'hel'

print_string_starts_with "hello" "hela"
# 'hello' does not start with 'hela'"

string_ends_with

#!/usr/bin/env import
import "string"

print_string_ends_with() {
  if string_ends_with "$1" "$2"; then
    echo "'$1' ends with '$2'"
  else
    echo "'$1' does not end with '$2'"
  fi
}

print_string_ends_with "hello" "llo"
# 'hello' ends with 'llo'

print_string_ends_with "hello" "lla"
# 'hello' does not end with 'lla'"

string_strikethrough

#!/usr/bin/env import
import "string"

echo "hello" | string_strikethrough
# h̶e̶l̶l̶o̶

About

String manipluation functions for shell scripts

https://import.pw/string

License:MIT License


Languages

Language:Shell 89.2%Language:Dockerfile 10.8%