String Functions
This page outlines the string operations you can perform using NetScript.
'string'
This function returns the string literal. Delimiter is single quote. Single quotes are not supported in string literals.
Function: 'string'
Data Type: string
Example:
'hello world'
Result:
hello world
'string1 + string2'
This function returns the string concatenation of the input
.
Function: string1 + string2
Data Type: string
Example:
'hello + world'
Result:
hello world
'string1 in string2'
This function returns a boolean statement indicating whether string1
is a substring of string2.
Function: string1 in string2
Data Type: boolean
Example:
'fruit' in 'Bowl of fruit'
'fruit' in 'Bowl of vegtables'
Result:
true
false
'string1 contains string2'
This function returns a boolean statement indicating whether string2
is a substring of string1.
Function: string1 contains string2
Data Type: boolean
Example:
'fruit' contains 'it'
'fruit' contains 'Bowl of fruit'
Result:
true
false
to_string(input)
This function returns the input
cast to string. Input
can be any value.
Function: to_string(input)
or tostring(input)
Data Type: string
Example:
to_string(5)
Result:
5
lowercase
This function converts string values to lower case.
Function: lowercase(input)
Data Type: string
Example:
lowercase('HELLO')
Result:
hello
substring
This function returns the substring of the input string.
Function: substring(input, number(, number))
Data Type: string
Example:
substring(‘netspring’, 1, 3)
Result:
net
regexp_instr
This function returns the lowest 1-based position of the substring in string that matches the regexp. 1st arg is the string to search in, 2nd arg is the regex to match. Returns null if either arg is null, throws error if the regex string is invalid, returns 0 if there is no match.
Function: regexp_instr
Data Type: string
Example:
regexp_instr(‘abc1’, ‘[0-9]’)
Result:
4
regexp_substr
This function returns the first substring that matches the regex. 1st arg is the string to search in, 2nd arg is the regex to match. Returns null if either arg is null or if there is no match, throws error if the regex string is invalid.
Function: regexp_substr
Data Type: string
Example:
regexp_substr(‘abc1’, ‘[0-9]’)
Result:
1
regexp_count
This function returns the number of times that a pattern (2nd arg) occurs in a string (1st arg).
Function: regexp_count
Data Type: string
Example:
regexp_count('abracadabra', 'bra')
Result:
2
regexp_replace
This function returns the subject (1st arg) with all occurrences of the pattern (2nd arg), replaced by a replacement string (3rd arg). If no matches are found, returns the original subject.
Function: regexp_replace
Data Type: string
Example:
regexp_replace('abc123', '[0-9]*', '_number')
Result:
abc_number
strlen
This function returns the number of characters in the given string.
Function: strlen
Data Type: string
Example:
strlen('hello')
Result:
5
trim
This function removes leading and trailing whitespace from a string.
Function: strlen
Data Type: string
Example:
trim(' a ')
Result:
'a'