Codeigniter's regex match

前端 未结 2 492
無奈伤痛
無奈伤痛 2020-12-10 20:14

I have this regular expression for validation in javascript:

/^(?:\'[A-z](([\\._\\-][A-z0-9])|[A-z0-9])*[a-z0-9_]*\')$/

Now I want the same

2条回答
  •  死守一世寂寞
    2020-12-10 20:19

    You might provide rules as an array :

    $this->form_validation->set_rules('username', 'Nombre de usuario', array('required', 'min_length[2]', 'max_length[15]', 'regex_match[/^(?:\'[A-z](([\._\-][A-z0-9])|[A-z0-9])*[a-z0-9_]*\')$/]', 'is_unique[user.username]'));
    

    This way regex with pipes won't crash

提交回复
热议问题