CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-clojure--clojure

Clojure core environment and runtime library providing a dynamic, general-purpose programming language on the JVM.

Pending
Overview
Eval results
Files

strings.mddocs/

String Processing

Comprehensive string manipulation utilities through the clojure.string namespace. All functions treat strings as immutable and return new strings.

Capabilities

Basic String Operations

Core string manipulation functions for common text processing tasks.

(clojure.string/join coll)
(clojure.string/join separator coll)  
;; Returns string of all elements in coll, optionally separated by separator
;; Returns: String

(clojure.string/split s re)
(clojure.string/split s re limit)
;; Splits string on regular expression, optionally limiting splits
;; Returns: vector of strings

(clojure.string/split-lines s)
;; Splits s on \n or \r\n
;; Returns: vector of strings

(clojure.string/replace s match replacement)
;; Replaces all instances of match with replacement in s
;; match can be string, character, or regex pattern
;; replacement can be string or function
;; Returns: String

(clojure.string/replace-first s match replacement)
;; Replaces first instance of match with replacement in s
;; Returns: String

(clojure.string/reverse s)
;; Returns s with characters in reverse order
;; Returns: String

Case Conversion

Functions for changing string case.

(clojure.string/upper-case s)
;; Converts string to all upper-case
;; Returns: String

(clojure.string/lower-case s)
;; Converts string to all lower-case  
;; Returns: String

(clojure.string/capitalize s)
;; Converts first character to upper-case, rest to lower-case
;; Returns: String

Whitespace Handling

Functions for trimming and managing whitespace.

(clojure.string/trim s)
;; Removes whitespace from both ends of string
;; Returns: String

(clojure.string/triml s)
;; Removes whitespace from left side of string
;; Returns: String

(clojure.string/trimr s)
;; Removes whitespace from right side of string
;; Returns: String

(clojure.string/trim-newline s)
;; Removes all trailing newline \\n or \\r\\n characters
;; Returns: String

String Predicates

Functions for testing string properties.

(clojure.string/blank? s) 
;; Returns true if s is nil, empty, or contains only whitespace
;; Returns: boolean

(clojure.string/starts-with? s substr)
;; Returns true if s starts with substr
;; Returns: boolean

(clojure.string/ends-with? s substr)
;; Returns true if s ends with substr  
;; Returns: boolean

(clojure.string/includes? s substr)
;; Returns true if s contains substr
;; Returns: boolean

String Search

Functions for finding substrings and positions.

(clojure.string/index-of s value)
(clojure.string/index-of s value from-index)
;; Returns index of first occurrence of value in s, optionally starting from from-index
;; Returns nil if not found
;; Returns: Long or nil

(clojure.string/last-index-of s value)
(clojure.string/last-index-of s value from-index)
;; Returns index of last occurrence of value in s, optionally starting from from-index
;; Returns nil if not found
;; Returns: Long or nil

String Transformation

Advanced string processing and transformation functions.

(clojure.string/escape s cmap)
;; Returns new string with character mapping applied
;; cmap is map of characters to replacement strings
;; Returns: String

(clojure.string/re-quote-replacement s)
;; Returns string with regex replacement special characters escaped
;; Use when replacement string contains $ or \
;; Returns: String

Core String Functions

Core Clojure functions that work with strings.

(str & xs)
;; Returns string representation of arguments concatenated
;; Calls toString on non-string arguments
;; Returns: String

(subs s start)
(subs s start end)
;; Returns substring from start (inclusive) to end (exclusive)
;; If no end specified, goes to end of string
;; Returns: String

(count s)
;; Returns number of characters in string
;; Returns: int

(nth s index)
(nth s index not-found)
;; Returns character at index, or not-found if out of bounds
;; Returns: Character

(seq s)
;; Returns sequence of characters in string
;; Returns: clojure.lang.ISeq or nil if empty

(char c)
;; Coerces c to character  
;; c can be Character, number, or keyword
;; Returns: Character

(int c)
;; Returns integer value of character
;; Returns: int

Regular Expressions

Clojure provides literal syntax and functions for regex processing.

(re-pattern s)
;; Compiles string into regex Pattern
;; Returns: java.util.regex.Pattern

(re-matcher pattern s)
;; Returns Matcher for pattern and string
;; Returns: java.util.regex.Matcher

(re-find matcher)
(re-find pattern s)
;; Returns next match from matcher, or first match of pattern in s
;; Returns: String or vector [match group1 group2 ...]

(re-matches pattern s)
;; Returns match if pattern matches entire string
;; Returns: String or vector [match group1 group2 ...] or nil

(re-seq pattern s)  
;; Returns lazy sequence of all matches
;; Returns: clojure.lang.LazySeq

;; Regex literal syntax
#"pattern"    ; Creates compiled Pattern object
#"(?i)pattern" ; Case-insensitive pattern

Usage Examples:

;; Basic operations
(clojure.string/join ", " ["apple" "banana" "cherry"])  ; => "apple, banana, cherry"
(clojure.string/split "a,b,c" #",")                     ; => ["a" "b" "c"]
(clojure.string/replace "hello world" "world" "there")  ; => "hello there"

;; Case conversion
(clojure.string/upper-case "hello")      ; => "HELLO"
(clojure.string/lower-case "WORLD")      ; => "world"  
(clojure.string/capitalize "hello")      ; => "Hello"

;; Whitespace handling
(clojure.string/trim "  hello  ")        ; => "hello"
(clojure.string/blank? "   ")            ; => true
(clojure.string/blank? "hello")          ; => false

;; String predicates
(clojure.string/starts-with? "hello world" "hello")  ; => true
(clojure.string/ends-with? "hello world" "world")    ; => true
(clojure.string/includes? "hello world" "lo wo")     ; => true

;; String search
(clojure.string/index-of "hello world" "world")      ; => 6
(clojure.string/last-index-of "hello hello" "hello") ; => 6

;; Core string functions
(str "hello" " " "world")                ; => "hello world"
(subs "hello world" 6)                   ; => "world"  
(subs "hello world" 0 5)                 ; => "hello"
(count "hello")                          ; => 5

;; Character operations
(nth "hello" 1)                          ; => \e
(seq "abc")                              ; => (\a \b \c)
(char 65)                                ; => \A
(int \A)                                 ; => 65

;; Regular expressions
(re-find #"\d+" "abc123def")             ; => "123"
(re-seq #"\w+" "hello world")            ; => ("hello" "world")
(re-matches #"\d{3}-\d{4}" "123-4567")   ; => "123-4567"

;; Advanced replacements  
(clojure.string/replace "hello world" #"\w+" str/upper-case) ; => "HELLO WORLD"
(clojure.string/escape "a<b>c" {\< "&lt;" \> "&gt;"})       ; => "a&lt;b&gt;c"

Install with Tessl CLI

npx tessl i tessl/maven-org-clojure--clojure

docs

concurrency.md

control-flow.md

core-language.md

data-structures.md

data-utilities.md

dev-tools.md

formats.md

index.md

io.md

java-interop.md

math.md

sequences.md

strings.md

testing.md

tile.json