'정규표현식'에 해당되는 글 2건

  1. 2012.07.10 정규표현식 한글
  2. 2012.07.10 PCRE 정규 표현식
php2012. 7. 10. 13:03




· 이제 아는 정규식을 총동원해서 규칙을 생성해주시면 됩니다! 말은 무지 간단하네요^^;


//C:\CodeIgniter_2.1.0\system\libraries\Form_validation.php

    /**
     * Convert PHP tags to entities
     *
     * @access    public
     * @param    string
     * @return    string
     */

    public function encode_php_tags($str)
    {
        return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
    }
    
    public function alpha_number_kr($str) { //특수문자, 한글, 영문, 숫자
        return ( ! preg_match("/^([\+\.\:\-_ 가-힣a-zA-Z0-9])+$/i", $str)) ? FALSE : TRUE;
    }
    
    public function alpha_kr($str) { //한글, 영문
        return ( ! preg_match("/^([가-힣a-zA-Z])+$/i", $str)) ? FALSE : TRUE;
    }
    
    public function id($str) { //맨 앞글자 반드시 영문, 그 뒤 영문, 숫자, 특수문자
        return ( ! preg_match("/^([a-zA-Z]+[a-zA-Z0-9\-\_\.])+$/i", $str)) ? FALSE : TRUE;
    }
    
    public function zero($str) { //숫자 0
        return ( $str == '0') ? FALSE : TRUE;
    }
    
    public function blank($str) { //빈칸
        return ( isset($str)) ? FALSE : TRUE;
    }
    
    public function noCheck($str) { //not 'no'
        return ( $str != 'no') ? FALSE : TRUE;
    }

Posted by 다오나무
php2012. 7. 10. 12:55



Posted by 다오나무