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.Expand 表4.16 Parameters Parameter Type stringstringstart positionnumberlength(Optional)numberExamples
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🐎abstring (horse symbol followed byaandb).
- string length( string )
Calculates the length of the specified string.
Expand 表4.17 Parameters Parameter Type stringstringExamples
string length( "tes" ) = 3 string length( "\U01F40Eab" ) = 3
- upper case( string )
Produces an uppercase version of the specified string.
Expand 表4.18 Parameters Parameter Type stringstringExample
upper case( "aBc4" ) = "ABC4"
- lower case( string )
Produces a lowercase version of the specified string.
Expand 表4.19 Parameters Parameter Type stringstringExample
lower case( "aBc4" ) = "abc4"
- substring before( string, match )
Calculates the substring before the match.
Expand 表4.20 Parameters Parameter Type stringstringmatchstringExamples
substring before( "testing", "ing" ) = "test" substring before( "testing", "xyz" ) = ""
- substring after( string, match )
Calculates the substring after the match.
Expand 表4.21 Parameters Parameter Type stringstringmatchstringExamples
substring after( "testing", "test" ) = "ing" substring after( "", "a" ) = ""
- replace( input, pattern, replacement, flags? )
Calculates the regular expression replacement.
Expand 表4.22 Parameters Parameter Type inputstringpatternstringreplacementstringflags(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
trueif the string contains the match.Expand 表4.23 Parameters Parameter Type stringstringmatchstringExample
contains( "testing", "to" ) = false
- starts with( string, match )
Returns
trueif the string starts with the matchExpand 表4.24 Parameters Parameter Type stringstringmatchstringExample
starts with( "testing", "te" ) = true
- ends with( string, match )
Returns
trueif the string ends with the match.Expand 表4.25 Parameters Parameter Type stringstringmatchstringExample
ends with( "testing", "g" ) = true- matches( input, pattern, flags? )
Returns
trueif the input matches the regular expression.Expand 表4.26 Parameters Parameter Type inputstringpatternstringflags(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.
Expand 表4.27 Parameters Parameter Type stringstringdelimiterstringfor 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","",""]