Andrew C. McGibbon
Andrew C. McGibbon

Reputation: 13

Regex Expression to Limit Character Count in Google Form

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

Answers (1)

Lucas Trzesniewski
Lucas Trzesniewski

Reputation: 51330

I don't know google forms, but a regex which can validate character count would be:

^.{0,200}$
  • The bit {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

Related Questions