Welcome Guest, Not a member yet? Register   Sign In
Quick question about regex_match
#1

When using regex_match, how would I be able to use the - character? An example of the code is posted below. What would be the correct format? Thanks! 
 
Code:
$rules = [
    'date' => 'required|min_length[2]|max_length[50]|regex_match[/^+[a-zA-Z0-9.- ]+$/]',
];
Reply
#2

Escape the - character with a backslash:
 
PHP Code:
$rules = [
    'date' => 'required|min_length[2]|max_length[50]|regex_match[/^+[a-zA-Z0-9.\- ]+$/]',
]; 
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

Thank you @includebeer it's working now.
Reply
#4

Regular expression tester trainer
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB