contains function

The fn:contains function determines whether a string contains a specific substring. The search string is matched using the default collation.

Syntax

Read syntax diagramSkip visual syntax diagramfn:contains( string, substring)
string
The string to search for substring.

string has the xs:string data type, or is the empty sequence. If string is the empty sequence, string is set to a string of length 0.

substring
The substring to search for in string.

substring has the xs:string data type, or is the empty sequence.

Limitation of length

The length of substring is limited to 32000 bytes.

Returned value

The returned value is the xs:boolean value true if either of the following conditions are satisfied:
  • substring occurs anywhere within string.
  • substring is an empty sequence or a string of length zero.
Otherwise, the returned value is false.

Example

The following function determines whether the string 'Test literal' contains the string 'lite'.
fn:contains('Test literal','lite')

The returned value is true.