String group

1. Contains tokens

Checks for the presence of a token in a given string.

2. Contains

Description

Checks for the presence of one or more values in a given string. If the string contains at least one value, then the result will be true. 

Format

has(arg_1, arg_s) → result

  • arg_1 : String — String
  • arg_s : String — Value
  • result : Boolean

Examples

  Example 1

has("hello world", "hello")

    • arg_1 : hello world
    • arg_2 : hello
    • result : true
  Example 2

has("hello world", "today")

    • arg_1 : hello world
    • arg_2 : today
    • result : false
  Example 3

has("In logs we trust", "Send", "logs", "now")

    • arg_1 : In logs we trust
    • arg_2 : Send
    • arg_3 : logs
    • arg_4 : now
    • result : true
  Example 4

"hello world" -> "world"

    • arg_1 : hello world
    • arg_2 : hello
    • result : true

This operation can also be written as arg_1 -> arg_s if there is only one arg_s and arg_s can be used one or more times.

3. Edit distance: Damerau

Description

Returns the Damerau edit distance between two strings. This distance, which is a variation of the Levenshtein distance, represents the minimum number of operations (insertions, deletions, substitutions and transpositions) required to transform one string into the other.

Format

damerau(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : String
  • result : Int

Examples

  Example 1

damerau("kitten", "sitten")

    • arg_1 : kitten
    • arg_2 : sitten
    • result : 1
  Example 2

damerau("aaxyaaxyaa", "aayxaayxaa")

    • arg_1 : aaxyaaxyaa
    • arg_2 : aayxaayxaa
    • result : 2
  Example 3

damerau("ca", "abc")

    • arg_1 : ca
    • arg_2 : abc
    • result : 2
  Example 4

damerau("ab", "ba")

    • arg_1 : ab
    • arg_2 : ba
    • result : 1
  Example 5

damerau("hello", "hello")

    • arg_1 : hello
    • arg_2 : hello
    • result : 0

4. Edit distance: Hamming

Description

Returns Hamming distance between two strings. This distance is the number of positions in which the corresponding symbols are different or the minimum number of changes required to transform one string into the other.

Format

hamming(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : String
  • result : Int

Examples

  Example 1

hamming('hello', 'mello')

    • arg_1 : hello
    • arg_2 : mello
    • result : 1
  Example 2

hamming('house', 'dog')

    • arg_1 : house
    • arg_2 : dog
    • result : 4
  Example 3

hamming('log', 'log')

    • arg_1 : log
    • arg_2 : log
    • result : 0

5. Edit distance: Levenshtein

Description

Returns the Levenshtein edit distance between two strings. This distance is the minimum number of operations (insertions, deletions and substitutions) required to transform one string into the other.  

Format

levenshtein(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : String
  • result : Int

Examples

  Example 1

levenshtein("kitten", "sitten")

    • arg_1 : kitten
    • arg_2 : kitten
    • result : 1
  Example 2

levenshtein("aaxyaaxyaa", "aayxaayxaa")

    • arg_1 : aaxyaaxyaa
    • arg_2 : aayxaayxaa
    • result : 4
  Example 3

levenshtein("ca", "abc")

    • arg_1 : ca
    • arg_2 : abc
    • result : 3
  Example 4

levenshtein("ab", "ba")

    • arg_1 : ab
    • arg_2 : ba
    • result : 2
  Example 5

levenshtein("hello", "hello")

    • arg_1 : hello
    • arg_2 : hello
    • result : 0

6. Edit distance: OSA

Description

Returns the OSA (optimal string alignment) edit distance between two strings. This distance, which is a variation of the Damerau distance, is the minimum number of operations (insertions, deletions, substitutions and transpositions) required to transform one string into the other, but with the condition that no substring is edited more than once.

Format

osa(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : String
  • result : Int

Examples

  Example 1

osa("kitten", "sitten")

    • arg_1 : kitten
    • arg_2 : sitten
    • result : 1
  Example 2

osa("aaxyaaxyaa", "aayxaayxaa")

    • arg_1 : aaxyaaxyaa
    • arg_2 : aayxaayxaa
    • result : 2
  Example 3

osa("ca", "abc")

    • arg_1 : ca
    • arg_2 : abc
    • result : 3
  Example 4

osa("ab", "ba")

    • arg_1 : ab
    • arg_2 : ba
    • result : 1
  Example 5

osa("hello", "hello")

    • arg_1 : hello
    • arg_2 : hello
    • result : 0

7. Ends with

Description

Returns strings that end with a specific suffix.

Format

endswith(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : String
  • result : Boolean

Examples

  Example 1

endswith("hello world", "ld")

    • arg_1 : hello world
    • arg_2 : Id
    • result : true
  Example 2

endswith("In logs we trust", "logs");

    • arg_1 : In logs we trust
    • arg_2 : logs
    • result : false

8. Format number

Description

Formats a number according to a format and locale, if specified. It is used to separate the digits following the specified format. The result will be a string formatted as specified, depending on the locale (if set).

  Special pattern characters
  • 0 → digit, zero padding (if the number is too short, zeros -in the locale's numeric set- will be added) 
  • # → digit, no zero padding (if the number is too short, there is no need of adding zeros) 
  • .  → decimal separator or monetary decimal separator 
  • -  → negative sign 
  • ,  → grouping separator 
  • % → multiply by 100 and show as percentage
  Locale examples
  • es, es_ES
  • en, en_US, en_GB, en_AU
  • fr, fr_FR


Format 1

  formatnumber(arg_1, arg_2) → result
  • arg_1 : Integer or Float — Number
  • arg_2 : String — Format
  • result : String

Format 2

  formatnumber(arg_1, arg_2, arg_3) → result
  • arg_1 : Integer or Float — Number
  • arg_2 : String — Format
  • arg_3 : String — Locale
  • result — String

Examples

  Example 1

formatnumber(1234567890, "#,###")

    • arg_1 : 1234567890
    • arg_2 : #,###
    • result : 1,234,567,890
  Example 2

formatnumber(1234.567, "#,###.0", "en")

    • arg_1 : 1234.567
    • arg_2 : #,###.0
    • arg_3 : en
    • result : 1,234.6
  Example 3

formatnumber(1234.567, "#,###.0", "es")

    • arg_1 : 1234.567
    • arg_2 : #,###.0
    • arg_3 : es
    • result : 1,234.6
  Example 4

formatnumber(0.55, "#%")

    • arg_1 : 0.55
    • arg_2 : #%
    • result : 55%

Using the same number and format may return different results depending on the locale value.

9. Length

Description

Returns the length of a string.

Format

length(arg_1) → result

  • arg_1 : String
  • result : Integer

Examples

  Example 1

length("hello")

    • arg_1 : hello
    • result : 5
  Example 2

length("In logs we trust");

    • arg_1 : In logs we trust
    • result : 16

10. Locate

Description

Returns the position of the first occurrence of a specified value in a string, counting from 0.  

Format

locate(arg_1, arg_2) → result

  • arg_1 : String — String
  • arg_2 : String — Substring to locate
  • result : Integer

Examples

  Example 1

locate("hello world", "o")

    • arg_1 : hello world
    • arg_2 : o
    • result : 4
  Example 2

locate("Mr Blue has a blue house and a blue car", "blue")

    • arg_1 : Mr Blue has a blue house and a blue car
    • arg_2 : blue
    • result : 14

Please note that this operation is case sensitive.

11. Lowercase

Description

Converts a string to lowercase. 

Format

lower(arg_1) → result

  • arg_1 : String
  • result : String

Examples

  Example 1

lower("HELLO WORLD")

    • arg_1 : HELLO WORLD
    • result : hello world
  Example 2

lower("In LOGS we TRUST");

    • arg_1 : In LOGS we TRUST
    • result : in logs we trust

12. Matches

Description

Checks if a string matches a regular expression. 

Format

matches(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : Regexp
  • result : Boolean

Examples

  Example 1

matches("hello world", re(".*lo"))

    • arg_1 : hello world
    • arg_2 : re(".*lo)
    • result : true
  Example 2

matches("name@test.xyz", re("^([^@]+)@(.+)$"))

    • arg_1 : name@test.xyz
    • arg_2 : re("^([^@]+)@(.+)$")
    • result : true
  Example 3

matches("name#test.xyz", re("^([^@]+)@(.+)$"))

    • arg_1 : name#test.xyz
    • arg_2 : re("^([^@]+)@(.+)$"")
    • result : false
  Example 4

"aaaa" ~ re("b*")

    • arg_1 : aaaa
    • arg_2 : re("b*")
    • result : false

This operation can also be written as arg_1 ~ arg_2

13. Peek

Description

Returns a string that matches the given regular expression or the content of the specified capturing group.

Format 1

  peek(arg_1, arg_2) → result
  • arg_1 : String
  • arg_2 : RegExp
  • result : String

Format 2

  peek(arg_1, arg_2, arg_3) → result
  • arg_1 : String
  • arg_2 : RegExp
  • arg_3 : Integer
  • result : String

Examples

  Example 1

peek('hello world', re('.*lo'))

    • arg_1 : hello world
    • arg_2 : re('.*lo)
    • result : hello
  Example 2

peek('name@test.xyz', re('^([^@]+)@(.+)$'))

  Example 3

peek('name@test.xyz', re('^([^@]+)@(.+)$'), 1)

    • arg_1 : name@test.xyz
    • arg_2 : re('^([^@]+)@(.+)$')
    • arg_3 : 1
    • result : name
  Example 4

peek('name@test.xyz', re('^([^@]+)@(.+)$'), 2)

    • arg_1 : name@test.xyz
    • arg_2 : re('^([^@]+)@(.+)$')
    • arg_3 : 2
    • result : test.xyz

String to regex conversion is implicit while using the operations dialogue box, so there is no need to do it explicitly as in the previous examples.

14. Replace all

Description

Searches in a string for a specific value and returns a new string where all the occurrences of this value (if any) are replaced.

Format

replaceall(arg_1, arg_2, arg_3) → result

  • arg_1 : String — String
  • arg_2 : String — Substring to search
  • arg_3 : String — Substring to replace
  • result : String

Examples

  Example 1

replaceall("Mr Blue has a blue house and a blue car", "blue", "green")

    • arg_1 : Mr Blue has a blue house and a blue car
    • arg_2 : blue
    • arg_3 : green
    • result : Mr Blue has a green house and a green car
  Example 2

replaceall("hello hello hello", "e", "a");

    • arg_1 : hello hello hello
    • arg_2 : e
    • arg_3 : a
    • result : hallo hallo hallo

Note that this operation is case sensitive.

15. Replace first

Description

Searches a string for a specified value and returns a new string where only the first occurrence of this value (if any) is replaced.

Format

replace(arg_1, arg_2, arg_3) → result

  • arg_1 : String — String
  • arg_2 : String — Substring to search
  • arg_3 : String — Substring to replace
  • result : String

Examples

  Example 1

replace("Mr Blue has a blue house and a blue car", "blue", "green")

    • arg_1 : Mr Blue has a blue house and a blue car
    • arg_2 : blue
    • arg_3 : green
    • result : Mr Blue has a green house and a blue car
  Example 2

replace("hello hello hello", "e", "a");

    • arg_1 : hello hello hello
    • arg_2 : e
    • arg_3 : a
    • result : hallo hello hello

Note that this operation is case sensitive.

16. Shannon entropy

Description

Returns the Shannon entropy of a given string.

Format

shannon(arg_1) → result

  • arg_1 : String 
  • result : Number

Examples

  Example 1

shannon("aa")

    • arg_1 : aa
    • result : 0
  Example 2

shannon("hello")

    • arg_1 : hello
    • result : 1.9219280948873625

17. Split

Description

Splits a string by a given literal separator and returns only the selected piece (counting from 0).

Format

split(arg_1, arg_2, arg_3) → result

  • arg_1 : String — String
  • arg_2 : String — Separator
  • arg_3 : Integer — Piece to return
  • result : String

Examples

  Example 1

split("123.456.789", ".", 1)

    • arg_1 : 123.456.789
    • arg_2 : .
    • arg_3 : 1
    • result : 456
  Example 2

split("In logs--we trust", "--", 0);

    • arg_1 : In logs--we trust
    • arg_2 : --
    • arg_3 : 0
    • result : In logs

18. Split regexp

Description

Splits a string by a given regular expression and returns only the selected piece (counting from 0).

Format

splitre(arg_1, arg_2, arg_3) → result

  • arg_1 : String — String
  • arg_2 : Regexp — Regexp separator
  • arg_3 : Integer — Piece to return
  • result : String

Examples

  Example 1

splitre("abc-123-cde-123-fgh", re("-[0-9]+-"), 1)

    • arg_1 : abc-123-cde-123-fgh
    • arg_2 : re("-[0-9]+-")
    • arg_3 : 1
    • result : cde
  Example 2

splitre("hello@abc-123world#xxx", re("[^\w]"), 2);

  • arg_1 : hello@abc-123world#xxx
  • arg_2 : re("[^\w]")
  • arg_3 : 2
  • result : 123world
  Example 3

splitre("hello@abc-123world#xxx", re("[^\w]"), 3);

  • arg_1 : hello@abc-123world#xxx
  • arg_2 : re("[^\w]")
  • arg_3 : 3
  • result : xxx

19. Starts with

Description

Returns strings that start with a specific prefix. 

Format

startswith(arg_1, arg_2) → result

  • arg_1 : String
  • arg_2 : String
  • result : Boolean

Examples

  Example 1

startswith("hello world", "he")

    • arg_1 : hello world
    • arg_2 : he
    • result : 5
  Example 2

startswith("In logs we trust", "rust");

    • arg_1 : In logs we trust
    • arg_2 : rust
    • result : false

20. Substitute

Description

Matches the first occurrence of a regular expression and substitutes it by a template. In case of failure, returns the original expression or returns the failed value (if given). 

Format 1

  subs(arg_1, arg_2, arg_3) → result
  • arg_1 : String — String to scan
  • arg_2 : Regexp — Regular expression
  • arg_3 : Template — Template
  • result : String

Format 2

  subs(arg_1, arg_2, arg_3, arg_4) → result
  • arg_1 : String — String to scan
  • arg_2 : Regexp — Regular expression
  • arg_3 : Template — Template
  • arg_4 : String — Fail value
  • result : String

Examples

  Example 1

subs("hello <insert sth here>", re("<.+$"), template("world"))

    • arg_1 : hello <insert sth here>
    • arg_2 : re("<.+$")
    • arg_3 : template("world")
    • result : hello world
  Example 2

subs("hello world", re("[0-9]+"), template("x"), "none")

    • arg_1 : hello world
    • arg_2 : re("[0-9]+")
    • arg_3 : template("x")
    • arg_4 : none
    • result : none
  Example 3

subs("123 456 789". re("[0-9]+"), template("*"), "---")

    • arg_1 : 123 456 789
    • arg_2 : re("[0-9]+")
    • arg_3 : template("*")
    • arg_4 : ---
    • result : * 456 789

21. Substitute all

Description

Substitutes all occurrences of a regular expression by a template.

Format

subsall(arg_1, arg_2, arg_3) → result

  • arg_1 : String — String to scan
  • arg_2 : Regexp — Regular expression
  • arg_3 : Template — Template
  • result : String

Examples

  Example 1

subsall("123 456 789". re("([0-9]+)\s"), template("\1-"))

    • arg_1 : 123 456 789
    • arg_2 : re("([0-9]+)\s")
    • arg_3 : template("\1-")
    • result : 123-456-789
  Example 2

subsall("123 ab 456 cdef 67ghi XYZ", re("([0-9]+)\s*([a-zA-Z]+)"), template("[\1\2]"))

    • arg_1 : 123 ab 456 cdef 67ghi XYZ
    • arg_2 : re("([0-9]+)\s*([a-zA-Z]+)")
    • arg_3 : template("\1\2")
    • result : [123ab] [456cdef] [67ghi] XYZ

22. Substring

Description

Extracts a substring from a given string(initial position and length). If the length is not specified, the right part of the resulting substring will be the same as the original string, as this value will be the difference between the total length and the initial position of the substring.

Format 1

  substring(arg_1, arg_2) → result
  • arg_1 : String — string
  • arg_2 : Integer — offset
  • result : String

Format 2

  substring(arg_1, arg_2, arg_3) → result
  • arg_1 : String — string
  • arg_2 : Integer — offset
  • arg_3 : Integer — length
  • result : String

Examples

  Example 1

substring("hello world", 6)

    • arg_1 : hello world
    • arg_2 : 6
    • result : world
  Example 2

substring("house and dog", 0, 5)

    • arg_1 : house and dog
    • arg_2 : 0
    • arg_3 : 5
    • result : house
  Example 3

substring("house and dog", 6, 3)

    • arg_1 : house and dog
    • arg_2 : 6
    • arg_3 : 3
    • result : and

23. Trim both sides

Description

Removes the white space from the beginning and the end of a string. 

Format

trim(arg_1) → result

  • arg_1 : String
  • result : String

Examples

  Example 1

trim("   hello world  ")

    • arg_1 : "   hello world  "
    • result : "hello world"
  Example 2

trim("  hello world")

    • arg_1 : "  hello world"
    • result : "hello world"
  Example 3

trim("hello world  ")

    • arg_1 : "hello world  "
    • result : "hello world"

24. Trim the left side

Description

Removes the white space from the beginning of a string.

Format

ltrim(arg_1) → result

  • arg_1 : String
  • result : String

Examples

  Example 1

ltrim("   hello world  ")

    • arg_1 : "   hello world  "
    • result : "hello world "
  Example 2

ltrim("  hello world")

    • arg_1 : "  hello world"
    • result : "hello world"
  Example 3

ltrim("hello world  ")

    • arg_1 : "hello world  "
    • result : "hello world "

25. Trim the right side

Description

Removes the white space from the end of a string. 

Format

rtrim(arg_1) → result

  • arg_1 : String
  • result : String

Examples

  Example 1

rtrim("   hello world  ")

    • arg_1 : "   hello world  "
    • result : "   hello world"
  Example 2

rtrim("  hello world")

    • arg_1 : "  hello world"
    • result : "  hello world"
  Example 3

rtrim("hello world  ")

    • arg_1 : "hello world  "
    • result : "hello world"

26. Upper case

Description

Converts a string to uppercase letters. 

Format

upper(arg_1) → result

  • arg_1 : String
  • result : String

Examples

  Example 1

upper("hello world")

    • arg_1 : hello world
    • result : HELLO WORLD
  Example 2

upper("In LOGS we TRUST");

    • arg_1 : In LOGS we TRUST
    • result : IN LOGS WE TRUST

Have we answered your question?

If not, please contact our technical support team via email by clicking the button below.

CONTACT US