Jump to content

Recommended Posts

Hi Guys

 

Bit stuck on this.

 

I have a textarea and as part of validating it I want to run a regex to ensure it matches my criteria. The problem is everytime I introduce a literal fullstop the check fails - even though it should be one of the acceptable characters.

 

The regex is as follows:

 

$pattern3 = '/^[a-zA-Z0-9"\'\.]{3,}$/';
if(!preg_match($pattern3, $posts['message'])){

  $errorsArray[] = 'Please provide a short description of your problem.';  

 }

 

Anyone point me in the right direction please?

Link to comment
https://forums.phpfreaks.com/topic/269409-noob-regex-issue/
Share on other sites

Add an s after the final slash to allow multiple lines.

 

Nah, the s modifier will allow the dot (as a metachar, not as a literal char inside the char class he has) to also match newline chars, but he is not using a dot in his pattern, he is using a character class, so the s modifier won't actually work. Assuming my shot in the dark is right, he needs to throw newline chars into the mix, and since he'd specifically be matching for them (either putting them in a char class or listing them as an alternation to the char class), s modifier wouldn't be applicable.

Link to comment
https://forums.phpfreaks.com/topic/269409-noob-regex-issue/#findComment-1385671
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.