Return a string with za colour codes replaced with ANSI values.
Example:
# Example for addansi
println addansi("[#cyan]Hello World[#-]") # \033[36mHello World\033[0m
Returns an ANSI code string for expressing an 8-bit background colour code.
Example:
# Example for bg256 println bg256(34) # \033[48;5;34m
Returns an ANSI code string for expressing an rgb background colour code.
Example:
# Example for bgrgb println bgrgb(255,0,0) # \033[48;2;255;0;0m
Format the input string in the manner of fprintf(). Also processes embedded colour codes to ANSI.
Example:
# Example for ccformat
println ccformat("Hello [#2]%s[#.]","World") # "Hello World" with World in red ink.
Remove curly brace nests from a string.
Example:
# Example for clean
println clean("a{b[pad field fields get_value has_start has_end match filter substr gsub replace trim lines count inset wrap next_match line_add line_delete line_replace line_add_before line_add_after line_match line_filter grep sgrep line_head line_tail is_utf8 reverse tr lower upper format ccformat literal pos bg256 fg256 bgrgb fgrgb split join collapse strpos stripansi addansi stripquotes stripcc clean rvalid levdist keys]}d") # ad
Turns a newline separated string into a space separated string.
Example:
# Example for collapse
println collapse("a\nb\nc") # "a b c"
Returns the number of lines in string_name.
Example:
# Example for count
println count("a\nb\nc") # 3
Returns an ANSI code string for expressing an 8-bit foreground colour code.
Example:
# Example for fg256 println fg256(31)+"hello"+fg256(0) # red hello text
Returns an ANSI code string for expressing an rgb foreground colour code.
Example:
# Example for fgrgb println fgrgb(255,0,0) # \033[38;2;255;0;0m
Retrieves columnar field position from input_string.
[#SOL]optional_separator defaults to a space character. string is empty on failure.
Example:
# Example for field
println field("a b c",2) # "b"
Splits up input_string in local array F, with fields starting at index 1.
[#SOL]Field count is stored in NF. Also squeezes repeat spaces when separator is a space char (default).
[#SOL]Returns -1 on error, or field count.
Example:
# Example for fields var txt="a b c" println fields(txt) # 3 println F # ["a","b","c"]
Returns a string matching the regular expression regex in string. count should be -1 for all matches.
Example:
# Example for filter
println filter("abc def","d") # "def"
Format the input string in the manner of fprintf().
Example:
# Example for format
println format("%s %d", "Age:", 30)
Returns the value of the key key_name in string_array.
Example:
# Example for get_value
var m={"key":"val"}
println get_value(m,"key") # val
Alias for line_filter.
Example:
# Example for grep var s="a\nb\nc" println grep(s,"b") # "b"
Returns string with all matches of string_m replaced with string_s.
Example:
# Example for gsub
println gsub("hello world","l","x") # hexxo worxd
Does string1 end with string2?
Example:
# Example for has_end
println has_end("abcdef","ef") # true
Does string1 begin with string2?
Example:
# Example for has_start
println has_start("abc","a") # true
Left pads each line of nl_string with distance cursor right commands.
Example:
# Example for inset var text="line1\nline2" println inset(text,4)
Checks for utf8 rune and returns width. 1 on no match.
Returns a string with all elements of string_list concatenated, separated by fs.
Example:
# Example for join println join(["a","b","c"],",") # "a,b,c"
Returns a list of map keys
Calculate Levenshtein edit distance between two strings.
Append a line to array string var.
Example:
# Example for line_add var s="a\nb\nc" println line_add(s,"d") # "a\nb\nc\nd"
Inserts a new line to array string var after the first matching regex.
Example:
# Example for line_add_after var s="a\nb\nc" println line_add_after(s,"b","inserted") # a\nb\ninserted\nc
Inserts a new line in string ahead of the first matching regex_string.
Example:
# Example for line_add_before var s="a\nb\nc" println line_add_before(s,"b","x") # a\nx\nb\nc
Remove lines from array string var which match regex.
Example:
# Example for line_delete var s="a\nb\nc" println line_delete(s,"b") # a\nc
Returns lines from nl_string where regular expression regex matches.
Example:
# Example for line_filter var s="a\nb\nc" println line_filter(s,"b") # "b"
Returns the top count lines of nl_string.
Example:
# Example for line_head
println line_head("a\nb\nc",2) # "a\nb"
Does nl_string contain a match for regular expression regex on any line?
Example:
# Example for line_match
println line_match("a\nb\nc","b") # true
Replaces lines in var that match regex with replacement.
Example:
# Example for line_replace var s="a\nb\nc" println line_replace(s,"b","x") # a\nx\nc
Returns the last count lines of nl_string.
Example:
# Example for line_tail
println line_tail("a\nb\nc",2) # "b\nc"
Returns lines from string_name. string_range is specified in the form start:end.
[#SOL]Either optional term can be last to indicate the last line of the file. Numbering starts from 0.
Example:
# Example for lines var s="a\nb\nc" println lines(s,"1:2") # "a\nb"
Format the input string.
Convert to lower-case.
Example:
# Example for lower
println lower("HELLO") # hello
Does string contain a match for regular expression regex?
Example:
# Example for match
println match("hello","ell") # true
Returns the next line number which contains the regex in nl_string. -1 is returned on no match.
Example:
# Example for next_match var t="a\nb\nc" println next_match(t,"b",1) # 2
Return left (-1), centred (0) or right (1) justified, padded string.
Example:
# Example for pad
println pad("abc",1,5,"*") # "**abc"
Returns a cursor positioning ANSI code string for (row,col).
Example:
# Example for pos println pos(10,20) # ANSI cursor string
Replaces matches found in var with regex to replacement.
Example:
# Example for replace
println replace("abc","b","B") # aBc
Reverse the contents of a variable.
Example:
# Example for reverse println reverse([1,2,3]) # [3,2,1]
Checks if a regex has valid syntax.
Search file for regex pattern with context. Options: .regex (required), .before (int), .after (int), .number (bool), .only_matching (bool).
[#SOL]Returns array of maps with line data and context. (map fields: .line,.linenum,.context_before_count,.context_after_count,.context_before[],.context_after[],.text[] when .only_matching=true
Returns string as a list, breaking the string on fs.
Example:
# Example for split
println split("a b c") # ["a","b","c"]
Remove escaped ansi codes.
Example:
# Example for stripansi var s=char(27)+"[31mred"+char(27)+"[0m" println stripansi(s) # "red"
Remove Za colour codes from string.
Example:
# Example for stripcc
println stripcc("[#red]red[#-]") # red
Remove outer quotes (double, single or backtick)
Example:
# Example for stripquotes
println stripquotes("'hello'") # hello
Returns the position of the next match of substring in string. Returns -1 if no match found.
Example:
# Example for strpos
println strpos("abcde","c") # 3
Returns a sub-string of string, from position int_s with length int_l.
Example:
# Example for substr
println substr("hello",1,3) # hel
delete (action "d") or squeeze (action "s") extra characters (in case_string) from string.
Translate (action "t") can be used, along with the optional translation_string to specify direct
replacements for existing characters. Please note: this is a very restricted subset of the tr tool.
Example:
# Example for tr
println tr("aabbcc","d","ab") # cc
Removes whitespace from string, depending on int_type.
-1 ltrim, 0 both, 1 rtrim. By default, space (ASCII:32) and horizontal tabs (ASCII:9) are removed.
Example:
# Example for trim
println trim(" a ",0) # "a"
Convert to upper-case.
Example:
# Example for upper
println upper("hello") # HELLO
Enable (true) or disable (false) line wrap in non-global display panes.
[#SOL]The previous wrap value is returned.
[#SOL]N.B. ensure that only plain text is wrapped. ANSI codes may be split!