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.
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:
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!