nakins Posted December 20, 2011 Share Posted December 20, 2011 I'm trying to validate form input that will be written directly into a csv file. I want to have a simple expression that only allows common name and addressing character, like # and @ and . and , and -. But everything I've tried doesn't seem to work. Does anyone have a expression that they use for general name and address validation? Quote Link to comment https://forums.phpfreaks.com/topic/253552-does-anyone-have-a-generic-regex-for-nameaddress/ Share on other sites More sharing options...
ragax Posted December 20, 2011 Share Posted December 20, 2011 If you want a regex to validate a name and address, that's a very, very tall call. But I think you know it and are asking for a first filter that only accepts certain characters. Is that right? Here is an example: [[:alnum:] .@#-]+ It allows alpha-numerical characters, spaces, periods, and the other characters between the brackets. Add any characters you like. If you want to use a backslash you will have to escape it, and possibly other special characters depending on their position in the brackets. Quote Link to comment https://forums.phpfreaks.com/topic/253552-does-anyone-have-a-generic-regex-for-nameaddress/#findComment-1299864 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.