With some fixes:
    
    
    import re, strutils
    
    let buf = """
    START
    {
      "start_h":10,
      "start_m":40,
      "end_h":11,
      "end_m":40,
      "delta_h":0,
      "delta_m":0,
      "project_ID":0
    }
    END
    """
    
    var
      dataBuf: string = ""
      buildingRecord: bool
    
    if "START" in buf:
      buildingRecord = true
    
    if buildingRecord:
      dataBuf.add(buf)
    
    if "END" in buf and buildingRecord:
      # Extract the message.
      var matches: array[1, string]
      var matched = find(dataBuf, re(r"START(.+)END", flags={reDotAll}), 
matches)
      
      if matched >= 0:
      # Or just:
      # if contains(dataBuf, re(r"START(.+)END", flags={reDotAll}), matches):
        echo(matches[0])
    
    
    Run

Reply via email to