Jump to content

validate input string with letters numbers and spaces


fael097

Recommended Posts

hi, i need a pregmatch that validades a string from a field with numbers, letters, and spaces only. maybe i could use dashes, commas and accented letters later, but i dont know anything about regex, and its kinda hard to learn it with the available tutorials, so i'd be happy to have just my first need.

someone can help?

thanks!

Link to comment
Share on other sites

i dont know anything about regex, and its kinda hard to learn it with the available tutorials

 

What about the "available tutorials" makes it hard to learn? Where have you looked so far? There is a lot of very good information out there from explaining the absolute basics of regular expressions to ultra-in-depth discussions. 

Link to comment
Share on other sites

Zach, how on earth is that comparable to what fael097 wants?

 

fael097, I can't do anything about the "extensive reading" (it's not really a lot... or if it is, you're probably re-reading the same thing over and over or not covering just the basics).

Link to comment
Share on other sites

It's the same thing as yours except mine has uses the shorthand \w ([a-zA-Z0-9])

Salathe hasn't posted a Regex in this thread, so it's not the same as his. Assuming you meant my pattern, it's still nowhere near the same. The OP wanted a pattern that would mean the string only contained those characters, which your pattern doesn't enforce at all, it merely checks there is at least one of them present. It also matches more characters since it will match underscore by default, and depending on the locale settings on the server potentially things such as accented characters.

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.