@jf/cc2sep
v2.0.0
Published
Transform a camelized string into a lowercased one using a custom separator and accepting unicode uppercase chars.
Downloads
1
Maintainers
Readme
@jf/cc2sep
Transform a camelized string into a lowercased one using a custom separator and accepting unicode uppercase chars.
You can modify regexp
property for customizing the text transformations in your application.
Arguments
- text: Text to convert.
- separator: Separator to use between words (
-
by defatul). - trim:
true
if you want to remove separators beginning or ending text (true
by default).
Examples
cc2sep(text)
'onceuponatime' => 'onceuponatime'
'onceUponATime' => 'once-upon-a-time'
'OnceUponATime' => 'once-upon-a-time'
'ONCE UPON A TIME' => 'o-n-c-e u-p-o-n a t-i-m-e'
'once-upon-a-time' => 'once-upon-a-time'
'innerHTML' => 'inner-h-t-m-l'
'ÁáááÉéééÍíÓóó' => 'áááá-éééé-íí-óóó'
cc2sep(text, '-', false)
'OnceUponATime' -> '-once-upon-a-time'
'ONCE UPON A TIME' -> '-o-n-c-e -u-p-o-n -a -t-i-m-e'
'ÁáááÉéééÍíÓóó' -> '-áááá-éééé-íí-óóó'