I found a quick project I thought would be perfect for learning F#. However I just cannot wrap my brain around it for some reason. After hours of tutorials and even some movies I still just... don't get it.
So I wanted to start versioning our stored procedures at work using Enterprise Manager "Generate Scripts" and wanted to blank out the script date. I gave up and did it in C# but now I'm REALLY curious and am hoping for some insight.
I am not completely empty handed, here is my C# code:
string path = @"C:\Subversion\CompanyName\SQL\DBName";
string fileSpec = "*.sql";
string pattern = @"Script Date: \d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2}";
string replace = "Script Date: ";
foreach (var file in Directory.EnumerateFiles(path, fileSpec))
{
string content = File.ReadAllText(file);
content = Regex.Replace(content, pattern, replace);
File.WriteAllText(file, content, Encoding.Unicode);
}
I am guessing there is some cool looking 2-3 line solution in F#... I'd love to see it.
Thx for the tips! I have updated it to match what is being done below to make the visual comparison potentially more enlightening. Also great comments below.