String Module
Jump to navigation
Jump to search
This XQuery Module contains functions for string operations and computations.
Conventions[edit]
All functions and errors in this module and errors are assigned to the http://basex.org/modules/string
namespace, which is statically bound to the string
prefix.
Computations[edit]
string:levenshtein[edit]
Signature | string:levenshtein( $string1 as xs:string, $string2 as xs:string ) as xs:double |
Summary | Computes the Damerau-Levenshtein Distance for two strings and returns a double value (0.0 - 1.0 ). The returned value is computed as follows:
|
Examples |
let $norm := ft:normalize(?, map { 'stemming': true() })
return string:levenshtein($norm("HOUSES"), $norm("house"))
|
string:soundex[edit]
Signature | string:soundex( $string as xs:string ) as xs:string |
Summary | Computes the Soundex value for the specified string. The algorithm can be used to find and index English words with similar pronouncation. |
Examples |
|
string:cologne-phonetic[edit]
Signature | string:cologne-phonetic( $string as xs:string ) as xs:string |
Summary | Computes the Kölner Phonetik value for the specified string. Similar to Soundex, the algorithm is used to find similarly pronounced words, but for the German language. As the first returned digit can be 0 , the value is returned as string.
|
Examples |
|
Formatting[edit]
string:format[edit]
Signature | string:format( $pattern as xs:string, $values... as item() ) as xs:string |
Summary | Returns a formatted string. The remaining $values are incorported into the $pattern , according to Java’s printf syntax.
|
Errors | format : The specified format is not valid.
|
Examples |
|
string:cr[edit]
Signature | string:cr() as xs:string
|
Summary | Returns a single carriage return character ( ).
|
string:nl[edit]
Signature | string:nl() as xs:string
|
Summary | Returns a single newline character ( ).
|
string:tab[edit]
Signature | string:tab() as xs:string
|
Summary | Returns a single tabulator character (	 ).
|
Changelog[edit]
- Version 10.0
- Updated: Renamed from Strings Module to String Module. The namespace URI has been updated as well.
- Updated:
string:format
,string:cr
,string:nl
andstring:tab
adopted from the obsolete Output Module.
The Module was introduced with Version 8.3. Functions were adopted from the obsolete Utility and Output Modules.