Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

substring-before


The substring-before function returns a string that is the rest of a given string before a given substring.

Syntax

substring-before( haystack , needle )

Arguments

haystack
The string to be evaluated. Part of this string will be returned.
needle
The substring to search for. Everything before the first occurance of needle in haystack will be returned.

Returns

A string.

Examples

XPath Example Output
substring-before('aa-bb','-') aa
substring-before('aa-bb','a') (empty string)
substring-before('aa-bb','b') aa-
substring-before('aa-bb','q') (empty string)

Defined

XPath 1.0 4.2

Gecko support

Supported.

Document Tags and Contributors

 Contributors to this page: Sheppy, Mgjbot, Docwhat, Dietrich, Ptak82, Jonnyq
 Last updated by: Sheppy,