Jump to content

at least 7 words separated by commas?


jamiet757

Recommended Posts

I am trying to figure out how to tell if what a user enters in a textbox is at least 7 words, separated by commas. It can be 100 words, I don't care, as long as it is at least 7. It will appear like this:

 

word1,word2,word3,word4,word5,word6,word7

 

or

 

word1, word2, word3, word4, word5, word6, word7 (with spaces)

 

Anyone have a statement that I can use?

 

Coincidentally, I need to check to see if there is at least 7 words in a sentence as well, i.e.:

 

The quick brown fox jumped over the.

 

It could be 100 words again, but it needs to be a minimum of 7.

 

Any help is appreciated!

Link to comment
Share on other sites

The previous code will work, but can be tricked with '      ' or ',,,,,,,,'. A better solution could be created with Regex if needed. Something like this to check for comma separated.

 

'#([^,]+,){7,}#i'

 

...and for the spaces...

 

'#([^ ]+ ){7,}#i'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.