We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 30b87ef commit 0cc0ba3Copy full SHA for 0cc0ba3
1 file changed
packages/nhsuk-frontend/src/nhsuk/components/character-count/character-count.mjs
@@ -25,6 +25,13 @@ export class CharacterCount extends ConfigurableComponent {
25
*/
26
segmenter = null
27
28
+ /**
29
+ * Split words between consecutive whitespace
30
+ *
31
+ * @type {RegExp}
32
+ */
33
+ separator = /\s+/g
34
+
35
/**
36
* @type {number | null}
37
@@ -485,7 +492,7 @@ export class CharacterCount extends ConfigurableComponent {
485
492
486
493
words(text) {
487
494
if (this.config.maxwords !== undefined) {
488
- return text.split(/\s+/g).filter(Boolean).length
495
+ return text.split(this.separator).filter(Boolean).length
489
496
}
490
497
491
498
const segments = this.segmenter
0 commit comments