-
Notifications
You must be signed in to change notification settings - Fork 4
The strings library
The strings library supplies functions for handling the built-in string type.
compare(a, b) returns an integer comparing two strings lexicographically. The result is 0 if a == b, -1 if a < b, and +1 if a > b.
contains(s, substr) reports whether substr is contained within s.
containsAny(s, chars) reports whether any Unicode code points in chars are within s.
count(s, substr) counts the number of non-overlapping instances of substr in s.
cut(s, sep) slices s around the first instance of sep, returning the text before and after sep.
equalFold(s, t) reports whether s and t, interpreted as UTF-8 strings, are equal under simple Unicode case-folding.
fields(s) splits s around one or more consecutive white-space characters.
hasPrefix(s, prefix) reports whether s begins with prefix.
hasSuffix(s, suffix) reports whether s ends with suffix.
index(s, substr) returns the index of the first instance of substr in s, or -1 if substr is not present in s.
indexAny(s, chars) returns the index of the first instance in s of any Unicode code point from chars, or -1 if none is present.
join(elems, sep) concatenates the elements of elems to create a single string separated by sep. It returns an error if elems contains a non-string value.
lastIndex(s, substr) returns the index of the last instance of substr in s, or -1 if substr is not present in s.
lastIndexAny(s, chars) returns the index of the last instance in s of any Unicode code point from chars, or -1 if none is present.
repeat(s, c) returns a new string consisting of c copies of s.
replace(s, old, new, n) returns a copy of s with the first n non-overlapping instances of old replaced by new.
replaceAll(s, old, new) returns a copy of s with all non-overlapping instances of old replaced by new.
split(s, sep) slices s into all substrings separated by sep.
splitAfter(s, sep) slices s into all substrings after each instance of sep and includes sep in the returned substrings.
splitAfterN(s, sep, n) slices s into substrings after each instance of sep and includes sep in the substrings returned.
splitN(s, sep, n) slices s into substrings separated by sep.
toLower(s) returns a copy of s with all Unicode letters mapped to their lower case.
toTitle(s) returns a copy of s with all Unicode letters mapped to their title case.
toUpper(s) returns a copy of s with all Unicode letters mapped to their upper case.
toValidUTF_8(s, replacementString) returns a copy of s with each run of invalid UTF-8 byte sequences replaced by replacementString.
trim(s, cutset) returns a slice of s with all leading and trailing Unicode code points contained in cutset removed.
trimLeft(s, cutset) returns a slice of s with all leading Unicode code points contained in cutset removed.
trimPrefix(s, prefix) returns s without the provided leading prefix. If s does not start with prefix, s is returned unchanged.
trimRight(s, cutset) returns a slice of s with all trailing Unicode code points contained in cutset removed.
trimSuffix(s, suffix) returns s without the provided trailing suffix. If s does not end with the suffix, s is returned unchanged.
This page is automatically generated from the Pipefish standard library. Any edits made directly to this wiki page will be overwritten the next time the documentation is regenerated.
🧿 Pipefish is distributed under the MIT license. Please steal my code and ideas.
- Getting started
- Language basics
- The type system and built-in functions
- Functional Pipefish
- Encapsulation
- Imperative Pipefish
-
Imports and libraries
- The crypto/aes library
- The crypto/bcrypt library
- The crypto/rand library
- The crypto/rsa library
- The crypto/sha_256 library
- The crypto/sha_512 library
- The database/sql library
- The encoding/base_32 library
- The encoding/base_64 library
- The encoding/csv library
- The encoding/json library
- The files library
- The fmt library
- The html library
- The image library
- The image/bmp library
- The image/color library
- The image/jpeg library
- The image/png library
- The lists library
- The markdown library
- The math library
- The math/big library
- The math/cmplx library
- The math/rand library
- The net/http library
- The net/mail library
- The net/smtp library
- The net/url library
- The os/exec library
- The path library
- The path/filepath library
- The reflect library
- The regexp library
- The strconv library
- The strings library
- The terminal library
- The time library
- The unicode library
- Advanced Pipefish
- Developing in Pipefish
- Deployment
- Appendices