home contribute faq download

FunctX XQuery Functions

functx:camel-case-to-words

Turns a camelCase string into space-separated words

Google
Webxqueryfunctions.com

Description

The functx:camel-case-to-words function turns a camel-case string (one that uses upper-case letters to start new words, as in "thisIsACamelCaseTerm"), and turns them into a string of words using a space or other delimiter.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to modify
$delim xs:string the delimiter for the words (e.g. a space)
return value xs:string

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:camel-case-to-words
  ( $arg as xs:string? ,
    $delim as xs:string )  as xs:string {

   concat(substring($arg,1,1),
             replace(substring($arg,2),'(\p{Lu})',
                        concat($delim, '$1')))
 } ;

Examples

XQuery ExampleResults
functx:camel-case-to-words(
     'thisIsACamelCaseTerm',' ')
this Is A Camel Case Term
functx:camel-case-to-words(
     'thisIsACamelCaseTerm',',')
this,Is,A,Camel,Case,Term

See Also

functx:words-to-camel-caseTurns a string of words into camelCase

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XQuery Services

Recommended Reading:

XQuery