# 单词首字母大写

> 将每个单词的首字母改为大写，其余字母不变

版本：1.0.0 · 作者 Deck

- 安装到 Deck：deck://install-plugin?id=capitalize-words&url=https%3A%2F%2Fgithub.com%2Fyuzeguitarist%2Fdeck-plugins%2Freleases%2Fdownload%2Fplugins%2Fcapitalize-words-1.0.0.zip
- 下载 .zip：https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/capitalize-words-1.0.0.zip
- 在 GitHub 上查看：https://github.com/yuzeguitarist/deck-plugins/tree/main/plugins/capitalize-words

也可以用终端安装：

```sh
mkdir -p ~/.deck/scripts/capitalize-words && curl -fsSL https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/capitalize-words-1.0.0.zip | tar -xf - -C ~/.deck/scripts/capitalize-words
```

## 脚本

```js
// Makes the first letter of every word upper case and leaves the other letters as they are.
function transform(input) {
  // A word starts at a letter that follows anything but a letter, mark, digit or apostrophe. An apostrophe
  // after a letter, mark or digit stays inside the word, as in don't and 1990's.
  return String(input ?? "").replace(
    /(^|[^\p{L}\p{M}\p{N}'\u2019]|(?:^|[^\p{L}\p{M}\p{N}])['\u2019])(\p{L})/gu,
    (match, before, letter) => before + letter.toUpperCase()
  );
}
```

---

- HTML：https://deckclip.app/zh-cn/plugins/capitalize-words
- English：https://deckclip.app/plugins/capitalize-words.md

© 2026 潘禹泽
