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!

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. 

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).

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.

Archived

This topic is now archived and is closed to further replies.

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