Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:15:32+00:00 2026-05-26T10:15:32+00:00

I found a quick project I thought would be perfect for learning F#. However

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:15:32+00:00Added an answer on May 26, 2026 at 10:15 am
    let path = @"C:\Subversion\CompanyName\SQL\DBName"
    let fileSpec = "*.sql"
    let pattern = @"Script Date: \d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2}"
    let replace = "Script Date: "
    
    Directory.EnumerateFiles (path, fileSpec)
    |> Seq.iter (fun file ->
        let content = Regex.Replace (File.ReadAllText file, pattern, replace)
        File.WriteAllText (file, content, Encoding.Unicode))
    

    Note that your C# code is (EDIT: was) also far more verbose than necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question regarding CSS and the browser. I tried searching SO and found some
Found some old code, circa VS 2003. Now I have just VS 2008 (SP1)
In writing some tests for a project I'm working on, I found that the
Just setting up some quick class and object item templates and all is working
I did a quick google on implementing clone() in Java and found: http://www.javapractices.com/topic/TopicAction.do?Id=71 It
Am thinking about a project which might use similar functionality to how Quick Add
I'm on a project where I was asked to take a quick peek at
My comany is using MS Project to handle ERP. But after a quick search
I'm just starting a project where I need to return POJOs from our mongo
I have a quick question that I haven't found out how to do efficiently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.