fork download
  1. import re
  2. pattern = r"\b[A-Z][a-z]+(?=([-\s]?))(?:\1[A-Z][a-z]+)*\b(?!-[A-Z])"
  3. text = "For the First Stage, you should press Start and you should follow Step-One and Step-Three. For the Final Stage, you must follow the sequence of steps One-Two-Five Seven // Steps One-Two-Five-Seven"
  4. print( list(set([x.group() for x in re.finditer(pattern, text)])) )
Success #stdin #stdout 0.02s 9624KB
stdin
Standard input is empty
stdout
['Step-Three', 'For', 'First Stage', 'Seven', 'One-Two-Five-Seven', 'Start', 'One-Two-Five', 'Steps', 'Step-One', 'Final Stage']