Google-forms – Regular expression in Google Form crashes browser tab

google-formsregex

I'm using a free text field in a Google Form. Users should be able to enter the name of a product followed by its price, then start a next line for the next product. To validate their entry I want to use regular expressions.

Example entries:

Coke .25 2.50
Beer 0,33 3.30 
Chai Latte Soy 4.50 
... and so on

These are the exact requirements for what a user can enter:

  • a string containing digits, letters, and other punctuation such as commas, spaces, periods, dashes etc. This string should be no longer than 20 characters tops.
  • a space (to separate the name of the product from its price)
  • a price value, min. "0.0" and max. "9999.99". It is important that the decimal is separated by a "." and not a ","
  • a line break after each product

This is what I have:

((\w|\s|\S){1,20}\s\d{1,4}\.\d{1,2}\s){1,50}

It works OK for the first two lines, but when I try to enter a third line the script breaks. My browser asks me to stop or debug the script.

What is wrong with the regular expression? Any pointers are appreciated!

Best Answer

Short answer

Looks that you found a failure on the user Google Forms user input sanitation. Please, on the Google Form editor, use the ? > Report a problem to let Google Form team engineers know about problem.

Explanation

A regular expression used as data validation rule should not make the browser through an error message. If the data validation is invalid, the Google Form should display an error message to the form editor.

Regarding the bonus question, that is the way that data validation work on Google Forms. You could also send feedback to Google about this too.

Related posts

Google Docs Help Forum

Google forms keeps failing to save when certain regular expressions are entered., posted on September 15, 2016