Jump to content

Does Anyone have a generic regex for name/address?


nakins

Recommended Posts

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?

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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