I am trying to validate strings in ruby. Any string which contains spaces,under scores or any special char should fail validation. The valid string should contain only chars a-z
If you are validating a line:
def validate(string) !string.match(/\A[a-zA-Z0-9]*\z/).nil? end
No need for return on each.