std.string.common

blank?

added in 3.0

(blank? s)

checks if string is empty or nil

(blank? nil) => true

(blank? "") => true

capital-case

added in 3.0

(capital-case s)

converts a string object to capital case

(capital-case “hello.World”) => “Hello.world”

((wrap capital-case) ’hello.World) => ’Hello.world

capitalize

added in 4.0

(capitalize s)

capitalize the first letter

(capitalize “hello”) => “Hello”

caseless=

added in 3.0

(caseless= x y)

compares two values ignoring case

(caseless= “heLLo” “HellO”) => true

((wrap caseless=) ’heLLo :HellO) => true

decapitalize

added in 4.0

(decapitalize s)

lowercase the first letter

(decapitalize “HELLO”) => “hELLO”

ends-with?

added in 3.0

(ends-with? s substr)

checks if string ends with another

(ends-with? “hello” “lo”) => true

((wrap ends-with?) ’hello ’lo) => true

escape

added in 3.0

(escape s cmap)

uses a map to replace chars

includes?

added in 3.0

(includes? s substr)

checks if first string contains the second

(includes? “hello” “ell”) => true

((wrap includes?) ’hello ’ell) => true

insert-at

(insert-at s i new)

join

added in 3.0

(join coll)(join seperator coll)

like join but used with ->> opts

(join “.” “a” “b” “c”) => “a.b.c”

;;(join “.” ’a b c) ;;=> ’a.b.c

joinl

added in 3.0

(joinl coll)(joinl coll separator)

joins an array using a separator

(joinl “a” “b” “c” “.”) => “a.b.c”

(joinl “a” “b” “c”) => “abc”

((wrap joinl) :a :b :c “-”) => :a-b-c

lower-case

added in 3.0

(lower-case s)

converts a string object to lower case

(lower-case “Hello.World”) => “hello.world”

((wrap lower-case) ’Hello.World) => ’hello.world

replace

added in 3.0

(replace s match replacement)

replace value in string with another

(replace “hello” “el” “AL”) => “hALlo”

((wrap replace) :hello “el” “AL”) => :hALlo

replace-all

added in 4.0

(replace-all s match re)

shortcut for .replaceAll

(replace-all “hello” “l” “o”) => “heooo”

replace-at

(replace-at s i new)

reverse

added in 3.0

(reverse s)

reverses the string

(reverse “hello”) => “olleh”

((wrap reverse) :hello) => :olleh

split

added in 3.0

(split s re)

splits the string into tokens

(split “a b c” #" ") => “a” “b” “c”

((wrap split) :a.b.c (re-pattern “.”)) => :a :b :c

split-lines

added in 3.0

(split-lines s)

splits the string into separate lines

(split-lines “a\nb\nc”) => “a” “b” “c”

starts-with?

added in 3.0

(starts-with? s substr)

checks if string starts with another

(starts-with? “hello” “hel”) => true

((wrap starts-with?) ’hello ’hel) => true

trim

added in 3.0

(trim s)

trims the string of whitespace

(trim " hello ") => “hello”

trim-left

added in 3.0

(trim-left s)

trims the string of whitespace on left

(trim-left " hello ") => "hello "

trim-newlines

added in 3.0

(trim-newlines s)

removes newlines from right

(trim-newlines “\n\n hello \n\n”) => "\n\n hello "

trim-right

added in 3.0

(trim-right s)

trims the string of whitespace on right

(trim-right " hello ") => “hello”

truncate

added in 3.0

(truncate s limit)

truncates a word

(truncate “hello there” 5) => “hello”

upper-case

added in 3.0

(upper-case s)

converts a string object to upper case

(upper-case “hello-world”) => “HELLO-WORLD”

((wrap upper-case) :hello-world) => :HELLO-WORLD