String Functions

ASCII()

ascii(s) - Returns ASCII code of the first byte of the argument s.

Example:
ascii('x') -> 120


CHR()
chr(i) - Converts an int ASCII code to a character.

Example:
chr(65) -> 'A'


CONCAT()
concat(s1,s2...) - Concatenates up to 5 strings.

Example: 
concat('a','bc','d') -> 'abcd'


INSTR()
instr(s1,s2) - Locates the first position of s2 inside s1.

Example: 
instr('abcd','cd') -> 3


LENGTH()
length(s) - Returns the length of string s

Example:
length('abcd') -> 4


LOCATE()

locate(s1,s2) - Locates the first position of s1 inside s2.

Example:
locate('b','abcabc') -> 2

locate(s1,s2, pos) - Locates the first position of s1 inside s2 from position pos.

Example:
locate('b','abcabc',4) →5


LOWER()
lower(s) - Converts s to lowercase.

Example: 
lower('AbCd')-> 'abcd'


REPLACE()
replace(s,sp, sr) - Replaces occurrences of string pattern sp in string s with replacement string sr. String pattern sp cannot be an empty string.

Example: 
replace('aCBef', 'CB', 'bcd') -> 'abcdef'


RIGHT()
right(s,n) - Returns the right part of a string s with the specified number of characters n. When n is negative, it returns the entire string s, with the exception of the first |n| characters.

Examples:
right('abcde', 2) > 'de'

right('abcde', -2)> 'cde'


SPACE()
space(n) - Returns a string that is composed of the specified number n of repeated spaces.

Example: 
space(1) -> ' '


SUBSTR()/SUBSTRING()
substr(s,start) - Removes a portion of the string s from position start.

Example:
substr('abcd',2) -> 'bcd'

substr(s,start,length)

Example: 
substr('abcd',2,1) -> 'b'

The function substring() is an alias for the function substr().


TRIM()/LTRIM()/RTRIM()
trim(s) - Removes whitespaces from both the left and the right sides of string s.

Example: 
trim (' a ') -> 'a'

ltrim(s) - Removes whitespaces from the left side of string s.

Example:
ltrim (' a ') -> 'a '

rtrim(s) - Removes whitespaces from the right side of string s.

Example:
rtrim ( a ') -> ' a'


UPPER()
upper(s) - Converts s to uppercase.

Example:
upper('AbCd') -> 'ABCD'