I have a question in a google-form for which I want to set a response validation to match "in 25 words or fewer".
The regex I've tried is ^(\b.+){1,25}$
but that isn't working: more than 25 words in one paragraph is validating, and 2 ten word paragraphs is invalidating.
I do want to allow multiple lines/paragraphs because people are people and they'll just get confused if it were not allowed.
These should pass:
- one two three? four five six, seven eight nine ten!
- one two three? four five six, seven eight nine ten! one two three? four five six, seven eight nine ten!
- here are twenty five simple words in three separate paragraphs.
one two three? four five six, seven eight nine ten!
one two three? four five - !bang !bang here are words starting with a non-word character
- here is a sentence ending in a word character
- here is a sentence ending in a non-word character!
These should fail:
- one two three? four five six, seven eight nine ten! one two three? four five six, seven eight nine ten! one two three? four five six, seven eight nine ten!
- one two three? four five six, seven eight nine ten!
one two three? four five six, seven eight nine ten!
one two three? four five six, seven eight nine ten!
Suggestions?
^(\b\B+){1,25}$
. And could you provide your sample lines? – Daniel^\w+(?:\W+\w+){0,25}$
from stackoverflow.com/questions/43889293/… but that fails if the text ends with non-whitespace characters. – Ericsgoogle-form
if they have a special syntax to specify if$
should match at the end of each line, or just the end of the whole text. – Daniel