I have got next code:

import std.stdio;
import std.regex;
import std.file;

void main()
{
        auto text = readText("book.txt");
        
        auto inlineCodeBlock = regex("`([^`\n]+)`");
        auto bigCodeBlock = regex(r"`{3}[\s\S]*?`{3}");
        
        foreach(t; text.matchAll(bigCodeBlock))
        {
                string t1 = t.hit.replaceFirst(regex("`"),`<code>`);
                string t2 = t1.replaceFirst(regex("`"),`</code>`);
        }
        
}

Here I am replacing `foo` to <code>foo</code>. But got replaced data as copy, not in original document. But I need to get replacing in original document.

replaceAll is not suitable for it because it's not clear how to get open and close tags (<code> and </code>).

Reply via email to