Jump to content

illegal characters


acctman

Recommended Posts

That's wrong. You must escape the hyphen or have it FIRST

 

/^[a-zA-Z0-9_\-]+$/

 

or

 

/^[-a-zA-Z0-9_]+$/

 

+ is a quantifier. It says match the class between 1 and infinite times, as many times as possible, giving back as needed.

$ matches the end of the string.

Link to comment
https://forums.phpfreaks.com/topic/100238-illegal-characters/#findComment-512540
Share on other sites

That's wrong. You must escape the hyphen or have it FIRST

 

/^[a-zA-Z0-9_\-]+$/

 

or

 

/^[-a-zA-Z0-9_]+$/

 

+ is a quantifier. It says match the class between 1 and infinite times, as many times as possible, giving back as needed.

$ matches the end of the string.

 

so the correct code would be

 


if(!preg_match('/^[a-zA-Z0-9_\-]+$/', $en['user']))
$err .= _reg_illegal.'<br>';

Link to comment
https://forums.phpfreaks.com/topic/100238-illegal-characters/#findComment-512565
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.