fork(11) download
  1. import re
  2. s = "Example=N ; Comment Line One error=\n\n; Comment Line Two.\n\nDesired=\n"
  3. config_value = 'Example'
  4. pattern=r'(?sm)^{}=(.*?)(?=[\r\n]+\w+=|\Z)'.format(config_value)
  5. match = re.search(pattern, s)
  6. if match:
  7. print(match.group(1))
Success #stdin #stdout 0.02s 6864KB
stdin
Standard input is empty
stdout
N      ; Comment Line One error=

; Comment Line Two.