fork download
  1. import re
  2.  
  3. patterns = [
  4. re.escape("hello(["),
  5. r"hello([",
  6. "hello(["
  7. ]
  8. for pattern in patterns:
  9. print("Pattern is {}".format(pattern))
  10. try:
  11. print(re.match(pattern=pattern, string="hello(["))
  12. except:
  13. print("Exception!")
  14.  
Success #stdin #stdout 0.02s 27744KB
stdin
Standard input is empty
stdout
Pattern is hello\(\[
<_sre.SRE_Match object; span=(0, 7), match='hello(['>
Pattern is hello([
Exception!
Pattern is hello([
Exception!