substring-before
XSLT/XPath Reference: XSLT elements, EXSLT functions, XPath functions, XPath axesThe substring-before
function returns a string that is the part 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 occurrence 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
Gecko support
Supported.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/substring-before