Camel Case
Last modified by Thomas Mortagne on 2021/03/18 11:29
Splits CamelCaseWords to separate words (Camel Case Words) |
Type | Snippet |
Category | |
Developed by | xwiki:XWiki.melv |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Code
{{velocity}}
## Assign text in Velocity script
#set ($text = 'This is MyText. Also with a LongCamelCaseWord. This is notACamelCase, though.')
## View old, before value
Old: $text
## Add space using regexp
#foreach ($i in [0..1000])
#set ($foreach.text = $text.replaceAll('\b(\p{Upper})(\S*?\p{Lower})(\p{Upper})', '$1$2 $3'))
#if ($foreach.text == $text)
#break($foreach)
#end
#set ($text = $foreach.text)
#end
## View new value
New: $text
{{/velocity}}
## Assign text in Velocity script
#set ($text = 'This is MyText. Also with a LongCamelCaseWord. This is notACamelCase, though.')
## View old, before value
Old: $text
## Add space using regexp
#foreach ($i in [0..1000])
#set ($foreach.text = $text.replaceAll('\b(\p{Upper})(\S*?\p{Lower})(\p{Upper})', '$1$2 $3'))
#if ($foreach.text == $text)
#break($foreach)
#end
#set ($text = $foreach.text)
#end
## View new value
New: $text
{{/velocity}}