I am looking for a regex that can identify in a sentence that consecutive words in a sentence start with capital letters.
If we take the text below as an example:
The A-Z Group is a long-established
market leader in the provision of
information for the global air cargo
community, and also for the defence
and security sectors through BDEC
Limited, publishers of the British
Defence Equipment Catalogue and
British Defence Industry Directory.
I want to be able to retrieve the following:
The A-Z Group
BDEC Limited Defence Equipment
Catalogue British Defence
IndustryDefence Industry
Is this even possible with a regex?
If so, can anyone suggest one?
(Update: I misunderstood your question at first.)
A simple case is
It may need to be modified if there are special cases of different language construct.
ruby-1.9.2-p0 > %Q{The A-Z Group is a long-established market leader in the provision of information for the global air cargo community, and also for the defence and security sectors through BDEC Limited, publishers of the British Defence Equipment Catalogue and British Defence Industry Directory.}.scan(/([A-Z][\w-]*(\s+[A-Z][\w-]*)+)/).map{|i| i.first}=> ["The A-Z Group", "BDEC Limited", "British Defence Equipment Catalogue", "British Defence Industry Directory"]