Strings extension for CEL — mirrors ext.Strings() from cel-go.
Provides extended string functions. Most string methods (charAt, indexOf,
substring, split, join, lowerAscii, upperAscii, trim, replace, reverse,
lastIndexOf) are available as built-ins. This module adds explicit
registration and the strings.quote global function.
Usage
env = Celixir.Environment.new() |> Celixir.Ext.Strings.register()
Celixir.eval!(~s|strings.quote("hello\nworld")|, env)
# => ""hello\\nworld""Functions (method style, on strings)
str.charAt(int)— character at indexstr.indexOf(string)/str.indexOf(string, int)— first occurrence indexstr.lastIndexOf(string)/str.lastIndexOf(string, int)— last occurrencestr.substring(int)/str.substring(int, int)— substringstr.split(string)/str.split(string, int)— split into liststr.join()/str.join(string)— join list of stringsstr.lowerAscii()— ASCII lowercasestr.upperAscii()— ASCII uppercasestr.trim()— trim leading/trailing whitespacestr.replace(old, new)/str.replace(old, new, int)— replace substringsstr.reverse()— reverse charactersstrings.quote(string)— safely quote a string for printing
Summary
Functions
Registers string extension functions into the given environment.