zsh - zmv - do not change case if there are more than one consecutive uppercase letters
I am using the following command
Code:
zmv -n -Q '(**/)(*[[:upper:]]*)(/)' '${1}${(L)${2//(#b)([[:upper:]])/-$match[1]}#-}' Code:
% tree Code:
% tree I do not want to lowercase if there are more than one consecutive uppercase letters. I just want to put `-` behind the capital letters given it is not in the beginning. Code:
% tree Code:
% zmv -n -Q '(**/)(*[[:upper:]]*)(/)' '${1}${(L)${2//(#b)([[:upper:]])/-$match[1]}#-}' Code:
mv -- FirstFolderToRename/DDDDDDD FirstFolderToRename/DDDDDDD |
Try to replace [[:upper:]] with [[:upper:]][[:lower:]] and (#b) with (#m):
Code:
'${1}${${2//(#m)[[:upper:]][[:lower:]]/-${(L)MATCH}}#-}' Consider doing this in two steps then. First, put dashes between words: Code:
zmv -n -Q '(**/)(*[A-Z]*)(/)' '$1${2//(#b)([a-z])([A-Z])/$match[1]-$match[2]}' Code:
zmv -n Q '(**/)(*[A-Z][a-z]*)(/)' '$1${2//(#m)[A-Z][a-z]/${(L)MATCH}}' |
Thank you very much. I have made a function like
Code:
function CamelToKebab() { Code:
function KebabToPascel() { |
I think the process should be simple
1. Capitalize First Character 2. Capitalize Every Character After `-` 3. Remove all `-` So far I have figured out 1 & 3. Code:
function KebabToPascal () { |
Alhamdulillah. The function that is working is
Code:
function kebabToPascal () { |
All times are GMT -5. The time now is 07:14 PM. |