fork download
  1. import re
  2.  
  3. sentence= "GPT3, BERT, and T5 are advanced NLP models from OpenAI and Google."
  4. match1 = re.findall(r'\b[A-Z]{2,}[0-9]\b', sentence)
  5. match2 = re.findall(r'[A-Z][a-z]+', sentence)
  6. match3 = re.findall(r'[A-Z].+?[a-z]', sentence)
  7. match4 = re.findall(r'[A-Z][A-Z0-9]+', sentence)
  8. print (match1)
  9. print (match2)
  10. print (match3)
  11. print (match4)
  12.  
Success #stdin #stdout 0.13s 15520KB
stdin
Standard input is empty
stdout
['GPT3']
['Open', 'Google']
['GPT3, BERT, a', 'T5 a', 'NLP m', 'Ope', 'AI a', 'Goo']
['GPT3', 'BERT', 'T5', 'NLP', 'AI']