Avatar of Eduardo Fuerte
Eduardo Fuerte
Flag for Brazil

asked on 

How to use preg_match function to test if a string has the allowed characters?

Hi Experts

Could you point a what must be changed  at preg_match function  to test if a string in a manner that:

Accept  only
"_"   (underline)
Any alphabetical character
Any numerical digit

So, doesn't accept:
"."    (point)
" "    (blank spaces)

Accordingly to:

  function alpha_only_space($str)

        if (!preg_match("/^([-a-z ])+$/i", $str))
            $this->form_validation->set_message('alpha_only_space', 'O nome deste %s campo deve conter apenas alfanuméricos');
            return FALSE;
            return TRUE;

Open in new window

Thanks in advance!
PHPMySQL ServerjQueryJSONJavaScript

Avatar of undefined
Last Comment
Eduardo Fuerte

8/22/2022 - Mon