Hi .. somebody around who is easy with Reg. Exressions. For me a nightmare. I have to Validate this format: 0-0000 0000 and/or 0-0000 0000/0 and/or 0-0000 0000/00 Would be a great help.. I have got: (^\d-\d{4} \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$) tried: validates :project_number, :format => { :with => /(^\d-\d{4} \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$)/, :message => "Message"} But that seems to be not valid. Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0845c172-a691-4924-b883-6c99bdc1a77a%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Hi, Try this http://www.regexpal.com Even I am not expert in Regexp but I always verify from here. This regular expression should work - /^\d-\d{4} \d{4}((/\d{2})|(/\d{1}))?$/ Aman Mangal 3rd year Undergraduate Department of Computer Science & Engineering IIT Bombay www.cse.iitb.ac.in/~amanmangal On Mon, May 27, 2013 at 5:08 PM, Werner <webagentur.laude-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>wrote:> Hi > .. somebody around who is easy with Reg. Exressions. > For me a nightmare. > > I have to Validate this format: 0-0000 0000 and/or 0-0000 0000/0 and/or > 0-0000 0000/00 > Would be a great help.. > > I have got: (^\d-\d{4} \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$) > > tried: > validates :project_number, :format => { :with => /(^\d-\d{4} > \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$)/, :message => "Message"} > > But that seems to be not valid. > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/0845c172-a691-4924-b883-6c99bdc1a77a%40googlegroups.com?hl=en-US > . > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL6Z3hyBK%2Baek7hKLxY2XwXy5y9j8X9CuL6-6sD1mCKDA9nAUQ%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On Mon, May 27, 2013 at 6:38 AM, Werner <webagentur.laude-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi > .. somebody around who is easy with Reg. Exressions. > For me a nightmare. > > I have to Validate this format: 0-0000 0000 and/or 0-0000 0000/0 and/or > 0-0000 0000/00\A\d\-\d{4}\s\d{4}(?:\/\d{1,2})?\Z - needs to be escaped, it''s a range indicator. Don''t use ^$ unless you want to be tricked by multi-line matches, which I''m sure is not what you want. For a simple regexp like the one you needed, the above simple one is much better, fancy regexps for simple cases is kinda annoying to manage.> Would be a great help.. > > I have got: (^\d-\d{4} \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$) > > tried: > validates :project_number, :format => { :with => /(^\d-\d{4} > \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$)/, :message => "Message"} > > But that seems to be not valid.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnz9nMUh5mRtJpVjWJ_N0mHWt7zRJe3cT_7H78H6LYdKXA%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Am 27.05.2013 um 16:33 schrieb Jordon Bedwell <envygeeks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> On Mon, May 27, 2013 at 6:38 AM, Werner <webagentur.laude-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> Hi >> .. somebody around who is easy with Reg. Exressions. >> For me a nightmare. >> >> I have to Validate this format: 0-0000 0000 and/or 0-0000 0000/0 and/or >> 0-0000 0000/00 > > \A\d\-\d{4}\s\d{4}(?:\/\d{1,2})?\Z > > - needs to be escaped, it''s a range indicator. Don''t use ^$ unless > you want to be tricked by multi-line matches, which I''m sure is not > what you want. For a simple regexp like the one you needed, the above > simple one is much better, fancy regexps for simple cases is kinda > annoying to manage.Thanks very much.. validates :project_number, :format => { :with => /\A\d\-\d{4}\s\d{4}(?:\/\d{1,2})?\Z/, :message => "Message"} works perfect..> >> Would be a great help.. >> >> I have got: (^\d-\d{4} \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$) >> >> tried: >> validates :project_number, :format => { :with => /(^\d-\d{4} >> \d{4}(/\d{2})?$)|(^I\d{8}$)|(^$)/, :message => "Message"} >> >> But that seems to be not valid. > > -- > You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/R1c2hgA_xWs/unsubscribe?hl=en-US. > To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnz9nMUh5mRtJpVjWJ_N0mHWt7zRJe3cT_7H78H6LYdKXA%40mail.gmail.com?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8816FA06-CF06-4E4B-A61C-F59F5C784248%40gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.