hhawkins Posted November 5, 2007 Share Posted November 5, 2007 I have this - $var = preg_replace("/[^A-Za-z0-9_, -]/", "", $var); But I want to add special characters to be allowed, is it as simple as /W? Or do I need to just add them individually? $var = preg_replace("/[^A-Za-z0-9_$!#, -]/", "", $var); This is feeding into a sql database should I not allow the use of / or \. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/76091-preg_replace-password/ Share on other sites More sharing options...
effigy Posted November 5, 2007 Share Posted November 5, 2007 What is not allowed--just slashes? Quote Link to comment https://forums.phpfreaks.com/topic/76091-preg_replace-password/#findComment-385175 Share on other sites More sharing options...
hhawkins Posted November 5, 2007 Author Share Posted November 5, 2007 Well what it is feeding into says everything is allowed - ! " # $ % & ( ) + , - / ; < = > ? [ \ ] ^ _ ` { | } * ' I want to attempt to allow that with out creating another issue. Quote Link to comment https://forums.phpfreaks.com/topic/76091-preg_replace-password/#findComment-385231 Share on other sites More sharing options...
effigy Posted November 5, 2007 Share Posted November 5, 2007 \W is the complement of [a-zA-Z0-9_], so it would function as if you used . with the /s modifier, effectively matching anything. You'll need to add these individually. Quote Link to comment https://forums.phpfreaks.com/topic/76091-preg_replace-password/#findComment-385247 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.