diff --git a/src/index.ts b/src/index.ts index 816c5573..56fec9f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,8 +32,8 @@ export function textToId(text: string): string { .normalize('NFD') // remove non-ASCII .replace(/\P{ASCII}/gu, '') - // replace 's followed by a space or end-of-line with s and the space/end match. - .replace(/'s(\s|$)/gu, 's$1') + // replace '\w followed by a space or end-of-line with \w and the space/end match. + .replace(/'(\w)(\s|$)/gu, '$1$2') // split along space or punction. .split(/[\s\p{P}]+/u) // exclude any elements that are empty when trimmed to avoid trailing _ for the join.