fork download
  1. import re
  2.  
  3. text_to_match = "This is a test string"
  4.  
  5. if re.match("string", text_to_match):
  6. print("Matched 'string'")
  7. elif re.match("This", text_to_match):
  8. print("Matched 'This'")
  9. else:
  10. pring("No match")
Success #stdin #stdout 0.01s 7896KB
stdin
Standard input is empty
stdout
Matched 'This'