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 251841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:37:42+00:00 2026-05-11T21:37:42+00:00

I am working with numbers a lot when editing a particular type of file,

  • 0

I am working with numbers a lot when editing a particular type of file, and it’s mostly tedious work. The file has a format like this:

damagebase = 8.834
    "abc_foo.odf" 3.77
    "def_bar.odf" 3.77
    "ghi_baz.odf" 3.77
    "jkl_blah.odf" 4.05
    ...

What would you recommend for writing a script that parses this and lets me programmatically change each number?

Language: i use C#, some F# (noob), and Lua. If you suggest regexes, could you provide specific ones as i am not familiar with them?

  • 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-11T21:37:42+00:00Added an answer on May 11, 2026 at 9:37 pm

    You can match runs of non-whitespace and punt to Double.Parse:

    int multiplier = 3;
    
    string input =
      "damagebase = 8.834\n" +
      "  \"abc.odf\" 3.77\n" +
      "  \"def.odf\" 3.77\n" +
      "  \"ghi.odf\" .77\n" +
      "  \"jkl.odf\" -4.05\n" +
      "  \"mno.odf\" 5\n";
    
    Regex r = new Regex(@"^(\w+)\s*=\s*(\S+)" +
                        @"(?:\s+""([^""]+)""\s+(\S+))+",
                        RegexOptions.Compiled | RegexOptions.Multiline);
    
    Match m = r.Match(input);
    if (m.Success) {
      double header = Double.Parse(m.Groups[2].Value);
      Console.WriteLine("{0} = {1}", m.Groups[1].Value,
                                     header * multiplier);
    
      CaptureCollection files = m.Groups[3].Captures;
      CaptureCollection nums  = m.Groups[4].Captures;
      for (int i = 0; i < files.Count; i++) {
        double val = Double.Parse(nums[i].Value);
        Console.WriteLine(@"  ""{0}"" {1}", files[i].Value,
                                            val * multiplier);
      }
    }
    else
      Console.WriteLine("no match");
    

    Running it gives

    damagebase = 26.502
      "abc.odf" 11.31
      "def.odf" 11.31
      "ghi.odf" 2.31
      "jkl.odf" -12.15
      "mno.odf" 15
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this regex working but now need to allow numbers without the decimal
I'm working with a database that has a bunch of serial numbers that are
I'm working on a Markdown command line program, and I'd like to format source
I need help working with very big numbers. According to Windows calc, the exponent
I have been working on a database that holds order numbers and order information.
I'm working on a program to factor very large numbers (20 digits or more)
I am working on a legacy system that generates confirmation numbers based on the
I am beginner in C# and I am working with floating point numbers. I
I have a requirement for a program I'm working on to store job numbers
I was using parseInt() to get some big prime numbers, but it's working as

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.