CopyQ icon indicating copy to clipboard operation
CopyQ copied to clipboard

Function with regex MaxMusterMann > Max Muster Mann

Open u53r55 opened this issue 2 years ago • 1 comments

I'm looking for a function that inserts a space before capital letters

"MaxMusterMann" > "Max Muster Mann" "OneTwoThreeFour" > "One Two Three Four"

Can anybody help me further? thanks :)

u53r55 avatar May 01 '22 05:05 u53r55

The following command add a menu/toolbar item that splits such word in selected item (here is how to add the command to CopyQ):

[Command]
Command="
    copyq:
    const text = str(input());
    const separated = text.replace(/[A-Z]/g, ' $&').trim();
    print(separated)"
Icon=\xf1dc
InMenu=true
Input=text/plain
Name=Separate CamelCase
Output=text/plain
Separator=\\n
Transform=true

Note: This is very simple command and works only on Latin characters and single word items.

hluk avatar May 07 '22 06:05 hluk