Difference between revisions of "String Module"
Jump to navigation
Jump to search
m (Text replacement - "'''Signatures'''" to "'''Signature'''") |
|||
Line 13: | Line 13: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|<pre>string:levenshtein( | |<pre>string:levenshtein( | ||
$string1 as xs:string | $string1 as xs:string | ||
Line 39: | Line 39: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|<pre>string:soundex( | |<pre>string:soundex( | ||
$string as xs:string | $string as xs:string | ||
Line 57: | Line 57: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|<pre>string:cologne-phonetic( | |<pre>string:cologne-phonetic( | ||
$string as xs:string | $string as xs:string | ||
Line 79: | Line 79: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|<pre>string:format( | |<pre>string:format( | ||
$format as xs:string | $format as xs:string | ||
Line 102: | Line 102: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|{{Code|'''string:cr()''' as xs:string}} | |{{Code|'''string:cr()''' as xs:string}} | ||
|- valign="top" | |- valign="top" | ||
Line 113: | Line 113: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|{{Code|'''string:nl()''' as xs:string}} | |{{Code|'''string:nl()''' as xs:string}} | ||
|- valign="top" | |- valign="top" | ||
Line 124: | Line 124: | ||
{| width='100%' | {| width='100%' | ||
|- valign="top" | |- valign="top" | ||
− | | width='120' | ''' | + | | width='120' | '''Signature''' |
|{{Code|'''string:tab()''' as xs:string}} | |{{Code|'''string:tab()''' as xs:string}} | ||
|- valign="top" | |- valign="top" |
Revision as of 15:03, 9 March 2023
Updated with Version 10: Renamed from Strings Module to String Module. The namespace URI has been updated as well.
This XQuery Module contains functions for string operations and computations.
Contents
Conventions
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
string:levenshtein
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 |
<syntaxhighlight lang="xquery"> let $norm := ft:normalize(?, map { 'stemming': true() }) return string:levenshtein($norm("HOUSES"), $norm("house")) </syntaxhighlight> |
string:soundex
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
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
The functions in this section have been adopted from the obsolete Output Module.
string:format
Signature | string:format( $format as xs:string $items as item() ... ) as xs:string |
Summary | Returns a formatted string. The remaining arguments specified by $items are applied to the $format string, according to Java’s printf syntax.
|
Errors | format : The specified format is not valid.
|
Examples |
|
string:cr
Signature | string:cr() as xs:string
|
Summary | Returns a single carriage return character ( ).
|
string:nl
Signature | string:nl() as xs:string
|
Summary | Returns a single newline character ( ).
|
string:tab
Signature | string:tab() as xs:string
|
Summary | Returns a single tabulator character (	 ).
|
Changelog
- 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.