Swap Name (Doe, John → John Doe)

transpose 2 words:

// #popclip
// name: Transpose words
// icon: iconify:ri:swap-box-line
// language: javascript
// regex: ^\w+\s\w+$
// after: paste-result
const words = popclip.input.text.split(" ");
return words[1] + " " + words[0];

transpose 2 characters:

// #popclip
// name: Transpose chars
// icon: iconify:ri:swap-box-fill
// language: javascript
// regex: ^\w\w$
// after: paste-result
return popclip.input.text[1] + popclip.input.text[0];

(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)