bottom

String Functions

Text Processing

The functions of this package allow you to implement basic text processing to extract, to transform, to search strings from parameters or other field values

LENGTH(strval) or SIZE(strval): size of a string

This function returns the number of characters of the parameter strval.

Example:

  • LENGTH(HELLO) returns "5"
  • LENGTH(1.5) returns "3".

PREFIX(strval,n): Prefix extraction

This function extracts the first n positions from the string strval.

Example:

  • PREFIX(HELLO,2) returns "HE"
  • PREFIX(HELLO,12) returns "HELLO"

SUFFIX(strval,n): Suffix extraction

This function extracts the suffix made of the last n positions from the string strval.

Example:

  • SUFFIX(HELLO,2) returns "LO"

SUBSTR(strval,pos,n): Substring extraction

This function allows to extract from the parameter "strval" the substring starting at the character of rank "pos" and of length "n". Note that the first rank of the string is 0.

Example:

  • SUBSTR(HELLO,2,2) returns "LL"

REPLACE(strval,pattern,strReplace): Substring substitution

This function replaces by "strReplace" all the substrings of "strval" that match the regular expression "pattern".

Example:

  • REPLACE("A number 123 or 456","[0-9]+","X") returns "A number X or X"

LOWER(strval): Lowercase conversion

This converts the parameter "strval" into lowercase. If a character from strval cannot be put into lowercase, its value remains the same.

Example:

  • LOWER("HELLO!") returns "hello!"

UPPER(strval): Uppercase conversion

This converts the parameter "strval" into uppercase. If a character from strval cannot be put into uppercase, its value remains the same.

Example:

  • UPPER(Hello!) returns "HELLO!"

LTRIM(strval,pattern): prefix removal(left trimering)

This function removes the largest prefix of strval matching the regular expression pattern.

Example:

  • LTRIM("YYYHELLOXXX","[Y]+") returns "HELLOXXX"

RTRIM(strval,pattern): suffix removal (right trimering)

This function removes the largest suffix of strval matching the regular expression pattern.

Example:

  • RTRIM("YYYHELLOXXX","[X]+") returns "YYYHELLO"

MATCH(pattern,strval): pattern matching

This function tests if the string strval matches the regular expression pattern. Note that the whole string must match with the pattern, not only a substring.

Examples:

  • MATCH("[X]+","HELLOXXX") returns "false".
  • MATCH("[0-9]+",SUM(25,MULT(2,4))) returns "true".

NBMATCHES(pattern,strval) : Number of matches

This function searches for the given pattern in strval and returns the number of matches.

Examples

  • NBMATCHES("l","Hello World") returns "3"
  • NBMATCHES("[0-9]+","Blabla 77364 Blabla 77354") returns "2"

URLENCODE(strval) : Encode strval for use in an URL / JSON

This function escapes special characters of parameter string in order to use it in a URL on any argument to ne passed through an URL such as for a JSON structure.

Examples

  • URLENCODE("HELLO WORLD") returns "HELLO+WORLD"

  • URLENCODE("Bonnie & Clyde") returns "Bonnie+%26+Clyde"

FORMAT(strval,left|right,Size,Compl) : string formatting

This function formats the string strval such that its size is equal to "Size".

If "Size" is greater than the actual size of "StrVal" then the character "Compl" will be added to "StrVal" either as a prefix or a suffix, depending on the specified direction (left or right).

If "Size" is smaller the the size of "StrVal", then the prefix or suffix of length "Size" is extracted, depending on the specified direction.

Example:

  • FORMAT("HELLO","left","8","X") returns "XXXHELLO"
  • FORMAT("HELLO","right","2","_") returns "LO"

Add comment


Security code
Refresh