Helloo.. how to make this below regular expression not to accept _ anywhere in the string /^[a-zA-Z0-9.]+[\w\s]*$/ how can i modify it.. Any Advices or Suggesions... Thanks -- Posted via http://www.ruby-forum.com/.
The dot (after the 9) means any character; if you remove it, it''s gonna only accept a-zA-Z0-9
Quoting Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Helloo.. > how to make this below regular expression not to accept _ anywhere in > the string > /^[a-zA-Z0-9.]+[\w\s]*$/ > how can i modify it.. > Any Advices or Suggesions... > Thanksif s =~ /_/ reject string end
The dot is probably not the issue here as it appears as part of a character sequence. If you don''t want to match with any ''_'' then replace the \w since it matches "alphanumeric + ''_''". It''s not clear to me what your intention is for the second set of square braces, but it looks like you''re trying to get grouping. You probably want parentheses instead. Try something like this: /^[0-9a-zA-Z.]+([0-9a-zA-Z]\s)*$/ -Donald Samer Abukhait wrote:> The dot (after the 9) means any character; if you remove it, it''s > gonna only accept a-zA-Z0-9 > > > >