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
https://forums.phpfreaks.com/topic/126057-regular-expression-simple-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.