Re: Where do you test syntax of D regexp online?

2017-03-10 Thread Suliman via Digitalmars-d-learn
On Friday, 10 March 2017 at 14:36:48 UTC, Suliman wrote: On Thursday, 9 March 2017 at 16:47:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 March 2017 at 16:40:13 UTC, Suliman wrote: How should I write to file result without \r\n\ symbols? auto x = content.matchFirst(bigCodeBlock); File f =

Re: Where do you test syntax of D regexp online?

2017-03-10 Thread Suliman via Digitalmars-d-learn
On Thursday, 9 March 2017 at 16:47:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 March 2017 at 16:40:13 UTC, Suliman wrote: 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); Just f.write(x[0]); to

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 9 March 2017 at 16:40:13 UTC, Suliman wrote: 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); Just f.write(x[0]); to write out the whole hit instead of the collection of references.

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
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

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 5:14 AM, Suliman wrote: Adding "r" helped: auto bigCodeBlock = regex(r"`{3}[\s\S]*?`{3}"); But now output is: [["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]] But I do not \r\n\ symbols... \r\n is Windows new line characters.

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
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

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
Adding "r" helped: auto bigCodeBlock = regex(r"`{3}[\s\S]*?`{3}"); But now output is: [["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]] But I do not \r\n\ symbols...

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
On Thursday, 9 March 2017 at 15:22:00 UTC, rikki cattermole wrote: On 10/03/2017 4:17 AM, Suliman wrote: I would use dpaste and write a quick script but here is where I think your problem is: regex("/.*/g") It should be: regex(".*", "g") As per[0]. [0]

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 4:17 AM, Suliman wrote: I would use dpaste and write a quick script but here is where I think your problem is: regex("/.*/g") It should be: regex(".*", "g") As per[0]. [0] http://dlang.org/phobos/std_regex.html#.regex Sorry, but what regexp are you talking? There is nothing

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
I would use dpaste and write a quick script but here is where I think your problem is: regex("/.*/g") It should be: regex(".*", "g") As per[0]. [0] http://dlang.org/phobos/std_regex.html#.regex Sorry, but what regexp are you talking? There is nothing like: `regex("/.*/g")` in my code...

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 3:50 AM, Suliman wrote: I wrote two regexp: auto inlineCodeBlock = regex("`(.*?)`"); // --> `(.*?)` auto bigCodeBlock = regex("/`{3}[\\s\\S]*?`{3}/g"); // --> `{3}[\s\S]*?`{3} First for for selection inline code block. Second for

Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
I wrote two regexp: auto inlineCodeBlock = regex("`(.*?)`"); // --> `(.*?)` auto bigCodeBlock = regex("/`{3}[\\s\\S]*?`{3}/g"); // --> `{3}[\s\S]*?`{3} First for for selection inline code block. Second for multi-line: #Header my