fn:contains function

The fn:contains function determines whether a string contains a given substring.

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.

Returned value

The returned value depends on the values of string and substring:
  • If string and substring are not the empty sequence, the returned value is true if substring occurs anywhere within string. If substring does not occur within string, the returned value is false.
  • If string is the empty sequence, the returned value is true if substring is the empty sequence or a string of length 0.
  • If substring is the empty sequence or a string of length 0, the returned value is true.

Example

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

The returned value is true.