Regex and manipulating files

Bloris loris.salvi at pm.me
Mon Nov 16 10:51:51 UTC 2020


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
     For example: "abc sdfs#=8 // some text" i've to take "8" 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,
Loris


More information about the Digitalmars-d-learn mailing list