digitalmars.D.learn - Regex and manipulating files
I've to convert a linux dash script because it is too slow and i decded to do it in D. I'm totally new to this and i think it could be a good exercise to learn this language. The shell script does some simple jobs like: 0) Run the script with some options 1) sed/grep regex to catch a portion of a file. For example: it finds the line that match "1234" and take all the lines until the line that match "abcd". 2) sed regex to catch some strings "some text" 3) Creates dirs and copy files 4) Add specific char to a specific column position at every row of a file Original file: abcdefghij 1234567890 c34vt59erj 04jèoàòr4t 14sdf7g784 Edited file: ab;cde;f;g;hij 12;345;6;7;890 c3;4vt;5;9;erj 04;jèo;à;ò;r4t 14;sdf;7;g;784 I would like to know what could be the best approach i would have to take with D to write simple, elegant and fast code, scanning files with more than 3000+ columns per line. Thank you, Loris
Nov 16 2020
On Monday, 16 November 2020 at 10:51:51 UTC, Bloris wrote:I've to convert a linux dash script because it is too slow and i decded to do it in D. I'm totally new to this and i think it could be a good exercise to learn this language. The shell script does some simple jobs like: 0) Run the script with some options 1) sed/grep regex to catch a portion of a file. For example: it finds the line that match "1234" and take all the lines until the line that match "abcd". 2) sed regex to catch some strings and "some text" 3) Creates dirs and copy files 4) Add specific char to a specific column position at every row of a file Original file: abcdefghij 1234567890 c34vt59erj 04jèoàòr4t 14sdf7g784 Edited file: ab;cde;f;g;hij 12;345;6;7;890 c3;4vt;5;9;erj 04;jèo;à;ò;r4t 14;sdf;7;g;784 I would like to know what could be the best approach i would have to take with D to write simple, elegant and fast code, scanning files with more than 3000+ columns per line. Thank you, Lorisregex you can use std.regex module https://dlang.org/phobos/std_regex.html IO stuff, read files, creatoe folders, etc: https://devdocs.io/d/std_stdio I'm not sure about performance, if you find it be slow, maybe there are something better at https://code.dlang.org/ it also depends on your algorithm/code, of course
Nov 16 2020