deno.land / std@0.224.0 / text / _util.ts

View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
export function splitToWords(input: string) { input = input.replaceAll(/[^a-zA-Z0-9\s-_]/g, ""); if (/[\s-_]+/.test(input)) return input.split(/[\s-_]+/); return input.split(/(?=[A-Z])+/);}
export function capitalizeWord(word: string): string { return word ? word?.[0]?.toLocaleUpperCase() + word.slice(1).toLocaleLowerCase() : word;}
std

Version Info

Tagged at
6 months ago