That's close. You want something like

/\A([A-Z]+[a-zA-Z]*)\s+([A-Z]+[a-zA-Z]*)\s+([A-Z]+[a-zA-Z]*)/

Which gives you

irb(main):021:0> x
=> "Having Jane Smith"
irb(main):022:0> x =~ /\A([A-Z]+[a-zA-Z]*)\s+([A-Z]+[a-zA-Z]*)\s+([A-Z]
+[a-zA-Z]*)/
=> 0
irb(main):023:0> $1
=> "Having"
irb(main):024:0> $2
=> "Jane"
irb(main):025:0> $3
=> "Smith"



On Mar 5, 12:21 am, Brijesh Shah <[email protected]> wrote:
> first you have to check whether there is three capital words are there
> or two..
>
> if str.match(/([A-Z]+[a-zA-Z]* [A-Z]+[a-zA-Z]* [A-Z]+[a-zA-Z]*)/)
>   # Do something
>
> elsif str.match/([A-Z]+[a-zA-Z]* [A-Z]+[a-zA-Z]*)/
>
>   # Do something
> end
>
> I  hope this will help u..
>
> Thanks
>
> Brijesh Shah
> --
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to