fn:contains

Check whether one string contains another.

Top of page

Related Syntax Constructs

The following construct(s) refer to this construct:


Syntax

fn:contains(string $string, string? $searchString) => boolean
fn:contains(string $string, string? $searchString, string $collation) => boolean

Description

This function checks whether the value of $string contains the value of $searchString anywhere. It returns true if it is found and false if not. There are some special cases in which this function returns the following values:

true the value of $string is a string of length zero
false the value of $searchString is a string of length zero

It is an error if either string value is an empty sequence.

Arguments

$string

string value

$searchString

string value that is searched for in $string

$collation

optional valid collation string literal

Examples

  • Is "ino" in "Tamino"?

    contains("Tamino", "ino")

    The function returns true, since "ino" is obviously contained in "Tamino".

  • Is the empty string part of another empty string?

    contains("", "")

    The function returns true.