Jump to content

Regular Expression simple question


kee2ka4

Recommended Posts

Hello Peeps,

 

I have use the following regular expression to validate my fields.

 

$post_validations = array('body'  => '/^[[:alnum:][:punct:][:space:]]{1,2000}$/');

 

Where the body field can start with any characters including space and punct and must have a minimum of one character to avoid empty values. My question is how can I add more validation to the regular exp so that if someone enters only a space character followed by no text, then the reg ex fails. So if I have the text '  this is an Example' then the reg exs passes as the character can start with a space but if I have the text '  ' then it should fail, since it only contains space tabs and no text, how can I add that validation to the reg ex

 

Thanks,

Zub

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.