4.3.2.3. String functions

The following functions support string operations.

注記

In FEEL, Unicode characters are counted based on their code points.

substring( string, start position, length? )

Returns the substring from the start position for the specified length. The first character is at position value 1.

表4.16 Parameters

ParameterType

string

string

start position

number

length (Optional)

number

Examples

substring( "testing",3 ) = "sting"
substring( "testing",3,3 ) = "sti"
substring( "testing", -2, 1 ) = "n"
substring( "\U01F40Eab", 2 ) = "ab"

注記

In FEEL, the string literal "\U01F40Eab" is the 🐎ab string (horse symbol followed by a and b).

string length( string )

Calculates the length of the specified string.

表4.17 Parameters

ParameterType

string

string

Examples

string length( "tes" ) = 3
string length( "\U01F40Eab" ) = 3

upper case( string )

Produces an uppercase version of the specified string.

表4.18 Parameters

ParameterType

string

string

Example

upper case( "aBc4" ) = "ABC4"

lower case( string )

Produces a lowercase version of the specified string.

表4.19 Parameters

ParameterType

string

string

Example

lower case( "aBc4" ) = "abc4"

substring before( string, match )

Calculates the substring before the match.

表4.20 Parameters

ParameterType

string

string

match

string

Examples

substring before( "testing", "ing" ) = "test"
substring before( "testing", "xyz" ) = ""

substring after( string, match )

Calculates the substring after the match.

表4.21 Parameters

ParameterType

string

string

match

string

Examples

substring after( "testing", "test" ) = "ing"
substring after( "", "a" ) = ""

replace( input, pattern, replacement, flags? )

Calculates the regular expression replacement.

表4.22 Parameters

ParameterType

input

string

pattern

string

replacement

string

flags (Optional)

string

注記

This function uses regular expression parameters as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

Example

replace( "abcd", "(ab)|(a)", "[1=$1][2=$2]" ) = "[1=ab][2=]cd"

contains( string, match )

Returns true if the string contains the match.

表4.23 Parameters

ParameterType

string

string

match

string

Example

contains( "testing", "to" ) = false

starts with( string, match )

Returns true if the string starts with the match

表4.24 Parameters

ParameterType

string

string

match

string

Example

starts with( "testing", "te" ) = true

ends with( string, match )

Returns true if the string ends with the match.

表4.25 Parameters

ParameterType

string

string

match

string

Example

ends with( "testing", "g" ) = true

matches( input, pattern, flags? )

Returns true if the input matches the regular expression.

表4.26 Parameters

ParameterType

input

string

pattern

string

flags (Optional)

string

注記

This function uses regular expression parameters as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

Example

matches( "teeesting", "^te*sting" ) = true

split( string, delimiter )

Returns a list of the original string and splits it at the delimiter regular expression pattern.

表4.27 Parameters

ParameterType

string

string

delimiter

string for a regular expression pattern

注記

This function uses regular expression parameters as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

Examples

split( "John Doe", "\\s" ) = ["John", "Doe"]
split( "a;b;c;;", ";" ) = ["a","b","c","",""]