brem13 Posted August 18, 2010 Share Posted August 18, 2010 hey, i was wondering how i would make a preg match check for special characters, i would only like to allow an underscore _ and a dash - i'm currently using preg_match("/[^0-9]+$/",$getUser) but thats not working right Quote Link to comment Share on other sites More sharing options...
btherl Posted August 18, 2010 Share Posted August 18, 2010 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. Quote Link to comment Share on other sites More sharing options...
brem13 Posted August 18, 2010 Author Share Posted August 18, 2010 thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.