home contribute faq download

FunctX XQuery Functions

fn:starts-with

Whether one string starts with another

Google
Webdatypic.com

Description

The fn:starts-with function returns an xs:boolean value indicating whether one string ($arg1) starts with the characters of another string ($arg2). Leading and trailing whitespace is significant, so you may want to use the fn:normalize-space function to trim the strings before using this function.

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 to test
$arg2 xs:string? the substring to check for
$collation xs:string the collation to use for comparing
return value xs:boolean

Examples

XQuery ExampleResults
starts-with('query', 'que')
true
starts-with('query', 'query')
true
starts-with('query', 'u')
false
starts-with('query', '')
true
starts-with('', 'query')
false
starts-with('', '')
true
starts-with('query', ())
true
starts-with(' query', 'q')
false

See Also

fn:ends-withWhether one string ends with another
fn:containsWhether one string contains another

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 XQuery Services

Recommended Reading:

XQuery