Jump to content

preg match for special chars


brem13

Recommended Posts

If you have a list of characters to allow, just list those characters, eg

 

preg_match("/^[0-9a-zA-Z_-]+$/", $getUser);

 

That allows 0-9, a-z, A-Z, underscore and dash only.  Make sure the dash appears last or first, so it doesn't get mistaken for a range of characters.

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.