User Tools

Site Tools


functions:character_string_functions

Functions

All these functions will manipulate character strings to fit your needs. Functions can use into conditional node and populate variable node and keep the result in a variable.

There are 3 groups of functions :

  1. Character string functions

Character string functions

  • ALL string inputs containing alphabetic characters (a-z, A-Z) must be encapsulated with single or double quotes.
  • If numeric character(s) (0-9) are used in functions that accept strings then the number will be treated as a string.
  • All functions can be nested (functions within functions).
  Usage description : $function(input-1 = "string", input-2 = integer[, optional input-3 = "string"/integer])
  • Escaping Doublequotes: If you need to provide a doublequote within your string, you need to escape them by just providing two doublequotes instead of one. Example:
    • your string is: [this is my “string”]
    • in a function, you need to use it this way: [“this is my ”“string”“”]
    • as you see, the string was wrapped into double quotes, just as any string inside functions. Additionally the real doublequotes in the string just have been doubled.

* If you want to read and store an entire text file (xml, txt, etc), see "$read" function.

$left vs $triml

  • $left : Get string n-characters from the left side.
  • $triml : Trim string n-characters from the left side.

Usages:
$left(input string = “string/%variable%”, number of characters to extract = integer/%i_variable%)
$triml(input string = “string/%variable%”, number of characters to trim = integer/%i_variable%)


$right vs $trimr

  • $right : Get string n-characters from the right side.
  • $trimr : Trim string n-characters from the right side.

Usages:
$right(input string = “string/%variable%”, number of characters to extract = integer/%i_variable%)
$trimr(input string = “string/%variable%”, number of characters to trim = integer/%i_variable%)


$middle vs $between

  • $middle : Get string n-characters from n-position.
  • $between: Get string between two strings.

Usages:
$middle(input string = “string/%variable%”, start position = integer/%i_variable%, number of characters to extract from start position = integer/%i_variable%)
$between(input string = “string/%variable%”, from string = “string/%variable%”, to string = “string/%variable%”[, instance found= integer/%i_variable%])


$upper vs $lower and $proper

  • $upper : Force string to upper case.
  • $lower : Force string to lower case.
  • $proper: Capitalizes every first letter following a non-alphanumeric character.

Usages:
$upper(input string = “string/%variable%”)
$lower(input string = “string/%variable%”)
$proper(input string = “string/%variable%”)


$replace and $alrep

  • $replace : Replace string in string. If “type” is set to 1 then the string to replace are split into characters.
  • $alrep : Replace all non-alphanumeric characters and add optional exceptions.

Usage:
$replace(input string = “string/%variable%”, string to replace = “string/%variable%” [, replace with string = “string/%variable%”, type = 0])
$alrep(input string = “string/%variable%”[, replace with string = “string/%variable%”][, except characters = “string/%variable%”])


$regreplace

  • $regreplace : Replace string in string by regex pattern.

Usage:
$regreplace(input string =“string/%variable%”, string to replace =“string/%variable%” [, replace with string =“string/%variable%”)


$leads vs $trails

  • $leads : Add leading character(s) to a string. If string to fill is omitted a zero (0) will be used.
  • $trails : Add trailing character(s) to a string. If fill-string is omitted a zero (0) will be used.

Usage:
$leads(input string = “string/%variable%”, total number of output characters = integer/%i_variable%[, string to fill = “string/%variable%”])
$trails(input string = “string/%variable%”, total number of output characters = integer/%i_variable% [, string to fill = “string/%variable%”])


$stripws and $stripcrlf

  • $stripws : Removes leading and trailing white spaces.
  • $stripcrlf : Removes carriage returns and line feeds from string.

Usage:
$stripws(input string = “string/%variable%”)
$stripcrlf(input string = “string/%variable%”)


$isdigit and $isalpha

  • $isdigit : Check if string is only numbers. Success returns 1, failure returns 0.
  • $isalpha : Check if string is only alphabetic letters. Success returns 1, failure returns 0.

Usage:
$isdigit(input string = “string/%variable%”)
$isalpha(input string = “string/%variable%”)


$length and $reverse

  • $length : List the number of characters.
  • $reverse : Reverse a string.

Usage:
$length(input string = “string/%variable%”)
$reverse(input string = “string/%variable%”)

length-reverse.jpg


Nested Functions

All functions can be nested (functions within functions).

Example 1: $replace($left(“my strings”, 6), “my”, “your”) your str

Example 2: $upper($triml($trimr(“function number 131 is useful”, 10), 9)) NUMBER 131


                                                                                                          Back to top

functions/character_string_functions.txt · Last modified: 2022/02/20 20:55 by benjamin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki