Visit Mozilla.org

XPath:Functions:substring-before

From MDC

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

Contents


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

[edit] Syntax

substring-before( haystack , needle )

[edit] 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.

[edit] Returns

A string.

[edit] 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)

[edit] Defined

XPath 1.0 4.2

[edit] Gecko support

Supported.