fork download
  1. import re
  2.  
  3. regex = r"(?<!\S)(keyword)[\t ]*\r?\n[\t ]*(\w+)(?!\S)"
  4. test_str = (" This is my keyword\n"
  5. " value")
  6.  
  7. matches = re.search(regex, test_str)
  8.  
  9. if matches:
  10. print('{} {}'.format(matches.group(1), matches.group(2)))
  11.  
Success #stdin #stdout 0.02s 9552KB
stdin
Standard input is empty
stdout
keyword value