Question: Does anybody have a regular expression that would work to limit the number of words in a response? For instance, I'd like to use it with jQuery validate so I can restrict a textbox/textarea to have say 250 words. The boxes will be plain-text.

I've done some Googling but none of the ones I've found were very good. They mostly centered around doing \b\w+\b but I had trouble getting it work.

Answer: 
This has worked well for me, for example if you want a 6-word limit:

```
^(?:\w+\W+){0,5}(?:\w+)$

```
To expand VonC's response, I found that by slightly modifying it, you can allow for basic punctuation and anywhere from 0 to 250 words.

```
^(?:\b\w+\b[\s\r\n\.\,\?\!]*){0,250}$

```