Reputation: 2121
I'm trying to create a format validation for a text field that will reject anything with whitespace. Can someone help me out with the RegEx syntax? This is what I've tried:
no_whitespace = /\A[\S]\z/i
validates :customurl, :format => { :with => no_whitespace }
I'm new to programming and clueless about RegEx. Any help would be greatly appreciated. Thanks!
Upvotes: 0
Views: 2240
Reputation: 4539
Try this:
no_whitespace = /^[\S]+$/
That should specify no whitespace characters from the beginning (^) the the end ($) of the string, and at least 1 character.
Upvotes: 4