Hi, Iam facing problem in excluding new line in reular expression...(/n) eg: shiva.grp\nhi da so it should exclude \n .if any one knows help me -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shiva Kumaran wrote:> Hi, > > Iam facing problem in excluding new line in reular expression...(/n) > eg: shiva.grp\nhi da so it should exclude \n .if any one knows help meExclude you don''t want it? [^\n] something like that or ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You''ll have to make the regexp multline with the /m option (i.e. /foo/ m) or it won''t match across newlines. Rein On Sep 3, 12:36 pm, Jamal Soueidan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Shiva Kumaran wrote: > > Hi, > > > Iam facing problem in excluding new line in reular expression...(/n) > > eg: shiva.grp\nhi da so it should exclude \n .if any one knows help me > > Exclude you don''t want it? > > [^\n] > > something like that or ? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rein Henrichs wrote:> You''ll have to make the regexp multline with the /m option (i.e. /foo/ > m) or it won''t match across newlines. > > Rein > > On Sep 3, 12:36 pm, Jamal Soueidan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thanks for your reply this is my regular expression my source is this mygroup.grp hi how r u iam fine str=~/^([a-zA-Z]{1}[a-zA-Z0-9]{0,}\.([a-zA-Z]{1,}))\s(.*)$/m if i put this regular expression it is not matching -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I need to understand, you don''t want anything after new line? or you want to remove \n and use your regular expression? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan wrote:> I need to understand, you don''t want anything after new line? > > or you want to remove \n and use your regular expression?its like this eg: shiva.grp hi how r u eg: shiva.grp hi how r u both this format should accept -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Shivan, I tried with this regex, it worked for both the example you mentioned. reg = /^[a-zA-Z]+\.[a-zA-Z]+[a-zA-Z ]+[\s]*$/ str = two example values you specified. str =~ reg -----> 0(output) On Sep 4, 1:18 pm, Shiva Kumaran <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Jamal Soueidan wrote: > > I need to understand, you don''t want anything after new line? > > > or you want to remove \n and use your regular expression? > > its like this > > eg: shiva.grp hi how r u > eg: shiva.grp > hi how r u > > both this format should accept > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
raghukumar wrote:> Hi Shivan, > I tried with this regex, it worked for both the example you mentioned. > > reg = /^[a-zA-Z]+\.[a-zA-Z]+[a-zA-Z ]+[\s]*$/ > > str = two example values you specified. > > str =~ reg -----> 0(output) > > > On Sep 4, 1:18 pm, Shiva Kumaran <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>irb(main):001:0> regexp = /^([a-zA-Z]\w*\.([a-zA-Z]+))\s(.*)$/m => /^([a-zA-Z]\w*\.([a-zA-Z]+))\s(.*)$/m irb(main):002:0> "mygroup.grp\nhi how r u\niam fine" =~ regexp => 0 irb(main):003:0> $1 => "mygroup.grp" irb(main):004:0> $2 => "grp" irb(main):005:0> $3 => "hi how r u\niam fine" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Rudy wrote:> raghukumar wrote: >> Hi Shivan, >> I tried with this regex, it worked for both the example you mentioned. >> >> reg = /^[a-zA-Z]+\.[a-zA-Z]+[a-zA-Z ]+[\s]*$/ >> >> str = two example values you specified. >> >> str =~ reg -----> 0(output) >> >> >> On Sep 4, 1:18 pm, Shiva Kumaran <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > irb(main):001:0> regexp = /^([a-zA-Z]\w*\.([a-zA-Z]+))\s(.*)$/m > => /^([a-zA-Z]\w*\.([a-zA-Z]+))\s(.*)$/m > irb(main):002:0> "mygroup.grp\nhi how r u\niam fine" =~ regexp > => 0 > irb(main):003:0> $1 > => "mygroup.grp" > irb(main):004:0> $2 > => "grp" > irb(main):005:0> $3 > => "hi how r u\niam fine"thnaks man for your help (str=~/^([a-zA-Z]{1}[a-zA-Z0-9]{0,}\.([a-zA-Z]{1,}))$/i) in the above expression it should not allow new line but it allowing inside pls help me....iam poor in regular expression -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
HI, how to validate a time in regular expression eg: alert 9916789067 05:16 wake up so i should validate time time can be 05:16 0516 05.16p 05.16p.m or pm 05.16a 05.16a.m or am 05:16a if any one knows help me -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2007/9/6, Shiva Kumaran <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > HI, > > how to validate a time in regular expression > > eg: alert 9916789067 05:16 wake up > > so i should validate time time can be >I didnt try it, you could try to use the validates_format_of (http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000945) method. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---