This is a trivial example using the Replace [Source Code 
Filter](https://nim-lang.org/docs/filters.html): 
    
    
    #? replace(sub="\t", by="  ")
    
    
    Run

I want to create my enhanced version where sub is a regexp: 
    
    
    #? regexReplace(sub="...", by="...")
    
    
    Run

Please help me a little. I only know the basic theory of files and regexes: 
    
    
    import os, re
    var
      newLine: string
      input = open("originalFile.nim")
      output = open("processedFile.nim", fmWrite)
      sub = re"..."
      by = "..."
    for line in input.lines:
      newLine = line.replacef(sub, by)
      output.writeLine(newLine)
    
    input.close
    output.close
    
    
    Run

Reply via email to