home contribute faq download

FunctX XSLT Functions

fn:substring-before

The substring before the first occurrence of a delimiter

Google
Webxsltfunctions.com

Description

The fn:substring-before function extracts all the characters of a string ($arg1) that appear before the first occurrence of another specified string ($arg2).

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$arg1 xs:string? the entire string
$arg2 xs:string? the string that ends the substring
$collation xs:string the collation to use to compare strings
return value xs:string

Examples

XPath ExampleResults
substring-before('query', 'r')
que
substring-before('query', 'ery')
qu
substring-before('queryquery', 'ery')
qu
substring-before('query', 'query')
zero-length string
substring-before('query', 'x')
zero-length string
substring-before('query', '')
zero-length string
substring-before('query', ())
zero-length string

See Also

functx:substring-before-lastThe substring before the last occurrence of a delimiter
functx:substring-before-if-containsPerforms substring-before, returning the entire string if it does not contain the delimiter
fn:substringA substring based on a starting point and optional length
fn:substring-afterThe substring after the first occurrence of a delimiter

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery