some help with writing a function that checks to see if a string
contains invalid characters. I have gotten it to work for spaces:
but I would like to perform a thorough check for all invalid
characters like my user validation:
validates_format_of :username, :with => /^[A-Z0-9_]*$/i
Im a little confused about the /^[A-Z0-9_]*$/i syntax. Can anyone
/^[A-Z0-9_]*$/i is a regular expression.
^ denotes starts with
[A-Z0-9_]* denotes 0 or more capitals, numbers and underscores
$ denotes ends_with
The i at the end means to ignore case (i think).
Thus your username can only contain letters, numbers and underscores
and nothing else.
The regular expression is contained between the //
The syntax should be the same for the actual regular expression.