We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 38ab2d5 commit 579f202Copy full SHA for 579f202
1 file changed
packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs
@@ -33,6 +33,13 @@ export class CharacterCount extends ConfigurableComponent {
33
*/
34
segmenter = null
35
36
+ /**
37
+ * Split words between consecutive whitespace
38
+ *
39
+ * @type {RegExp}
40
+ */
41
+ separator = /\s+/g
42
+
43
/** @private */
44
$visibleCountMessage
45
@@ -497,7 +504,7 @@ export class CharacterCount extends ConfigurableComponent {
497
504
498
505
words(text) {
499
506
if (this.config.maxwords !== undefined) {
500
- return text.split(/\s+/g).filter(Boolean).length
507
+ return text.split(this.separator).filter(Boolean).length
501
508
}
502
509
503
510
const segments = this.segmenter
0 commit comments