substring-before
The substring before the first occurrence of a delimiter
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).
Parameters |
Description |
---|---|
arg1:string() |
the entire string |
arg2:string() |
the string that ends the substring |
collation:string() |
the collation to use to compare strings |
Examples
XPath |
Results |
---|---|
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 |