The Strings Util
Python SDK, Javascript SDK
Provide a number of functions to manipulate strings. The Python and Javascript SDKs provide different functions.
The following common functions are provided:
truncate(string, max_len=50)
: truncate a long stringformat_log_line(severity, module, text)
: format a log line for printing
Python
hex2string(hex)
: convert a hex string into a ascii string
Javascript
capitalizeFirst(string)
: capitalize the first letterreplaceAll(search, replacement)
: replace all instances of search in replacementget_exception(e)
: return stack trace exceptiontopic_matches_sub(pattern, topic)
: javascript implementation of topic_matches_subformat_multiline(string, length)
: format a multiline string by enforcing a maximum lengthescape_html(string)
: escape html special characters in a string