XQuery
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 1491915103
2nd edition, , O'Reilly Media, Inc.
Chapter 18: Working with Strings
Please note that the book contains many inline examples and informal tables that are not provided here.
Example | Return value |
---|---|
contains("query", "ery")
|
true
|
contains("query", "x")
|
false
|
contains-token("xml query", "query")
|
true
|
contains-token( ("xml", "query"), "query")
|
true
|
starts-with("query", "que")
|
true
|
starts-with("query", "u")
|
false
|
ends-with("query", "y")
|
true
|
ends-with("query ", "y")
|
false
|
Example | Return value |
---|---|
matches("query", "q")
|
true
|
matches("query", "qu")
|
true
|
matches("query", "xyz")
|
false
|
matches("query", "q.*")
|
true
|
matches("query", "[a-z]{5}")
|
true
|
Example | Return value |
---|---|
substring("query", 2, 3)
|
uer
|
substring("query", 2)
|
uery
|
substring-before("query", "er")
|
qu
|
substring-before("queryquery", "er")
|
qu
|
substring-after("query", "er")
|
y
|
substring-after("queryquery", "er")
|
yquery
|
Example | Return value |
---|---|
string-length("query")
|
5
|
string-length(" query ")
|
7
|
string-length(normalize-space(" query "))
|
5
|
string-length("")
|
0
|
string-length(" ")
|
1
|
Example | Return value |
---|---|
tokenize("a b c", "\s")
|
("a", "b", "c")
|
tokenize("a b c", "\s+")
|
("a", "b", "c")
|
tokenize("a-b--c", "-")
|
("a", "b", "", "c")
|
tokenize("-a-b-", "-")
|
("", "a", "b", "")
|
tokenize("a/ b/ c", "[/\s]+")
|
("a", "b", "c")
|
tokenize("2015-12-25T12:15:00", "[\-T:]")
|
("2015", "12", "25", "12", "15", "00")
|
tokenize("Hello, there.", "\W+")
|
("Hello", "there")
|
Example | Return value |
---|---|
upper-case("query")
|
QUERY
|
upper-case("Query")
|
QUERY
|
lower-case("QUERY-123")
|
query-123
|
lower-case("Query")
|
query
|
Example | Return value |
---|---|
replace("query", "r", "as")
|
queasy
|
replace("query", "qu", "quack")
|
quackery
|
replace("query", "[ry]", "l")
|
quell
|
replace("query", "[ry]+", "l")
|
quel
|
replace("query", "z", "a")
|
query
|
replace("query", "query", "")
| A zero-length string |
Example | Return value |
---|---|
normalize-space("query")
|
query
|
normalize-space(" query ")
|
query
|
normalize-space("xml query")
|
xml query
|
normalize-space(" xml query ")
|
xml query
|
normalize-space(" ")
| A zero-length string |