Where do you test syntax of D regexp online?

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 9 08:40:13 PST 2017


On Thursday, 9 March 2017 at 16:23:23 UTC, Adam D. Ruppe wrote:
> On Thursday, 9 March 2017 at 16:14:28 UTC, Suliman wrote:
>> But now output is:
>> [["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]]
>>
>> But I do not \r\n\ symbols...
>
> That's just the writeln array formatter. The matchFirst 
> function returns an array of hits (that allows captures, btw 
> you might need to use \( instead of ( to get the capture, god i 
> hate regex) so writeln tries to print the whole array and 
> that's how it does embedded newlines.
>
> So you have the correct result, just written strangely.

How should I write to file result without \r\n\ symbols?

auto x = content.matchFirst(bigCodeBlock);

File f = File("foo.txt", "w");
f.write(x);

foo.txt:
["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]


More information about the Digitalmars-d-learn mailing list