Awkl
Loading...
Searching...
No Matches
str.awk File Reference

Namespaces

namespace  str
 

Functions

auto str::idx (string s, number i) -> string|number
 Index a string as if first character has index 1.
 
auto str::idx0 (string s, number i) -> string|number
 Index a string as if first character has index 0, with negative indexing.
 
string str::slice (string s, number a, number b)
 Slice a string as if first character has index 1.
 
string str::slice0 (string s, number a, number b)
 Slice a string as if first character has index 0.
 
auto str::find (string s1, string s2, number a, number b) -> string|number
 Lowest index starting from 1 where a substring is found in a string or its slice starting from 1.
 
auto str::find0 (string s1, string s2, number a, number b) -> string|number
 Lowest index starting from 0 where a substring is found in a string or its slice starting from 0.
 
auto str::indices (array R, string s1, string s2)
 Get indices, starting from 1, where a substring is found in a string, non-overlapping.
 
auto str::rfind (string s1, string s2, number a, number b) -> string|number
 Highest index starting from 1 where a substring is found in a string or its slice starting from 1.
 
auto str::rfind0 (string s1, string s2, number a, number b) -> string|number
 Highest index starting from 0 where a substring is found in a string or its slice starting from 0.
 
unassigned str::partition (array A, string s, string sep)
 Split the string at the first occurrence of a separator.
 
unassigned str::rpartition (array A, string s, string sep)
 Split the string at the last occurrence of a separator.
 
number str::splitLines (string s, array A)
 Split lines in a string at line boundaries.
 
string str::join (array A, string s=" ")
 Join array elements with separator.
 
number str::startsWith (string s1, string s2)
 Check if string starts with specific prefix.
 
number str::endsWith (string s1, string s2)
 Check if string ends with specific suffix.
 
string str::rep (string s, number n)
 Repeat string n number of times.
 
string str::escapeRe (string s)
 Escape regex special characters.
 
string str::replaceIdx (string s, string rep, number idx)
 Replace a character in a specific index with a string.
 
string str::replaceRange (string s, string rep, number i, number n)
 Replace a string in a specific index range with a string. Similar to substr()
 
string str::rmPrefix (string s, string pre)
 Remove matching prefix.
 
string str::rmSuffix (string s, string suf)
 Remove matching suffix.
 
string str::lstrip (string s, string chars)
 Remove leading characters.
 
string str::rstrip (string s, string chars)
 Remove trailing characters.
 
string str::strip (string s, string chars)
 Remove leading and trailing characters.
 
unassigned str::chars (array A, string s, number i0=1)
 Fill indexed array with characters in a string.
 
unassigned str::fields (array A)
 Fill indexed array with awk fields.
 
string str::lc (string s)
 Lower case.
 
string str::uc (string s)
 Upper case.
 
auto str::ucfirst (s)
 Upper case first character.
 
auto str::lcfirst (s)
 Lower case first character.
 
string str::tc (string s)
 Title case a string.
 
string str::tclc (string s)
 Title case a string and rest lower case.
 
string str::ltrim (string s)
 Remove leading blanks.
 
string str::rtrim (string s)
 Remove trailing blanks.
 
string str::trim (string s)
 Remove leading and trailing blanks.
 
string str::chop (string s, number n=1)
 Remove last characters.
 
string str::chomp (string s)
 Remove last character if it is linebreak \n
 
string str::rev (string s)
 Revert string.
 
string str::chr (number n)
 Chr function.
 
auto str::_ord_init (number l=0, number h=1114111)
 Fill the ord table.
 
number str::ord (string s)
 Ord function.
 
string str::indent (string s, string|number i)
 Indent.
 
string str::ljust (string s, number w, string c=" ", number l)
 Left justify.
 
string str::rjust (string s, number w, string c=" ", number l)
 Right justify.
 
auto str::serialize (x)
 Serialized representation of a string.
 
string str::repr (any x)
 String representation of a variable.
 
string str::csvQuote (string s)
 CSV-quote a string.
 
auto str::comb ()
 

Variables

string str::lower = "abcdefghijklmnopqrstuvwxyz"
 Lower-case letters in ASCII. Like POSIX [:lower:]
 
string str::upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 Upper-case letters in ASCII. Like POSIX [:upper:]
 
string str::digit = "0123456789"
 Digits in ASCII. Like POSIX [:digit:]
 
string str::alpha = lower upper
 Alphabetic characters in ASCII. Like POSIX [:alpha:]
 
string str::alnum = alpha digit
 Alphanumeric characters in ASCII. Like POSIX [:alnum:]
 
string str::word = alnum "_"
 Alphanumeric characters and _
 
string str::xdigit = "abcdefABCDEF" digit
 Hexadecimal digits in ASCII. Like POSIX [:xdigit:]
 
string str::blank = " \t"
 Blank characters in ASCII: space and tab. Like POSIX [:blank:]
 
string str::space = " \t\r\n\v\f"
 Space characters in ASCII: space, tab, carriage return, linebreak, vertical tab and form feed. Like POSIX [:space:]
 
string str::ascii
 ASCII characters.
 
string str::cntrl
 Control characters in ASCII. Unicode C0 control code. Like POSIX [:cntrl:]
 
string str::graph
 Graphical characters: Alphanumeric characters and punctuations. Like POSIX [:graph:]
 
string str::print_ = " " graph
 Printable characters: Space and graphical characters. Like POSIX [:print:]
 
string str::punct = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
 Punctuation characters in ASCII. Like POSIX [:punct:]
 
string str::ascii_letters = alpha
 
string str::ascii_lowercase = lower
 
string str::ascii_uppercase = upper
 
string str::digits = digit
 
string str::hexdigits = xdigit
 
string str::octdigits = "01234567"
 Octal digits in ASCII.
 
string str::punctuation = punct
 
string str::whitespace = space
 
string str::printable = digit alpha punct space
 
string str::linebounds = "\n\r\v\f\034\035\205\342\200\250\342\200\251"
 Single character line boundaries.
 
number str::_ordtab_init = 0
 
array str::ORDTAB [1]