Some tips on regexp's:
^ - match at beginning.
$ - match at end.
\d - match any number 0 to 9.
\w - match any letter A - Z, lowercase a -z, any numbers 0-9 as well as the underscore _.
\s - match whitespace, normally only tab and spaces.
[] - character class, match anything inside the brackets.
* - match 0 or more occurrences.
+ - match 1 or more occurrences.
? - match 0 or 1 occurence.
From that list, you say you want to allow letters, numbers or spaces, but nothing weird like ^{& etc. You could then use:
^[\w\s]+$
if you wanted at least something to be filled in (note the plus for one or more).
or
^[\w\s]*$
if the field can be left blank (note the star meaning zero or more). Be sure to explain to your users what you are seeking, because this will cough up an error if they try to use any punctuation like apostrophe's, etc.
Also, note: accents are considered different in perl!! So a é is not the same as a e. If you want to allow accents, you have to put those into the character class like:
^[\w\dé]*$
Hope that helps,
Alex
^ - match at beginning.
$ - match at end.
\d - match any number 0 to 9.
\w - match any letter A - Z, lowercase a -z, any numbers 0-9 as well as the underscore _.
\s - match whitespace, normally only tab and spaces.
[] - character class, match anything inside the brackets.
* - match 0 or more occurrences.
+ - match 1 or more occurrences.
? - match 0 or 1 occurence.
From that list, you say you want to allow letters, numbers or spaces, but nothing weird like ^{& etc. You could then use:
^[\w\s]+$
if you wanted at least something to be filled in (note the plus for one or more).
or
^[\w\s]*$
if the field can be left blank (note the star meaning zero or more). Be sure to explain to your users what you are seeking, because this will cough up an error if they try to use any punctuation like apostrophe's, etc.
Also, note: accents are considered different in perl!! So a é is not the same as a e. If you want to allow accents, you have to put those into the character class like:
^[\w\dé]*$
Hope that helps,
Alex