Reputation: 13
I am trying to get a regular expression working in Google forms to limit the number of characters in a form. I have tried a number of strings of code I have found online, but it does not seem to work.
The first string I tried was this, and it actually seemed to work for a bit but then stopped working:
[\w]{1,800}
The second I tried was this:
^\W*(\w+(\W+|$)){1,200}$
Does anyone have any suggestions as to why these won't work? Also, should it be "regular expression", and then "contains" or "Matches?
Upvotes: 1
Views: 4405
Reputation: 51330
I don't know google forms, but a regex which can validate character count would be:
^.{0,200}$
{0,200}
means between 0 and 200, so change that according to your needs..
is a placeholder for any character.^
and $
are begin and end of string anchors. They make sure the regex won't match in the middle of the string.Upvotes: 2