Ad
Algorithms
Logic
Code
Diff
  • import re
    def get_nth_words(tmpl, num):
        return ' '.join(re.search(r'(\w*)[\W]?'*(tmpl.count(" ")+1), tmpl).groups()[num-1::num] if num > 0 else list())
        
    • get_nth_words=lambda s,n: ' '.join(s.split()[n-1::n] if n>0 else [])
    • import re
    • def get_nth_words(tmpl, num):
    • return ' '.join(re.search(r'(\w*)[\W]?'*(tmpl.count(" ")+1), tmpl).groups()[num-1::num] if num > 0 else list())