• Skip to main content
  • Skip to search
  • Skip to select language
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. XPath
  3. Functions
  4. contains
  • Change language

contains

XSLT/XPath Reference: XSLT elements, EXSLT functions, XPath functions, XPath axes

The contains function determines whether the first argument string contains the second argument string and returns boolean true or false.

Syntax

contains(haystack, needle)

Arguments

haystack

The string to be searched

needle

The string to look for as a substring of haystack

Returns

true if haystack contains needle. Otherwise, false.

Defined

XPath 1.0 4.2

Gecko support

Supported.

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Jan 19, 2022, by MDN contributors

Change your language
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2022 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies