Description
The functx:reverse-string function reverses the order of characters in a string. It returns a zero-length string if the argument is the empty sequence.
Arguments and Return Type| Name | Type | Description |
$arg |
xs:string? |
the string to reverse |
| return value |
xs:string |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for April 2005 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:reverse-string
( $arg as xs:string? ) as xs:string {
codepoints-to-string(reverse(string-to-codepoints($arg)))
} ; | | XQuery Syntax for July 2004: |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:reverse-string
( $arg as xs:string? ) as xs:string {
string-join(
for $i in (0 to (string-length($arg) - 1))
return substring($arg, string-length($arg) - $i,1), '')
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function reverse-string
( $arg as xs:string? ) as xs:string {
fn:string-join(
for $i in (0 to (fn:string-length($arg) - 1))
return fn:substring($arg, fn:string-length($arg) - $i,1), '')
} |
Examples| XQuery Example | Results |
|---|
functx:reverse-string('abc')
|
cba
|
functx:reverse-string('a')
|
a
|
See AlsoHistory |
|