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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:42:31+00:00 2026-05-23T20:42:31+00:00

I have a large string that has a series of floating points in string.

  • 0

I have a large string that has a series of floating points in string. A typical string would have Item X $4.50 Description of item \r\n\r\n Item Z $4.75... There is really no rhyme or reason for the text. I have the lowest already and I need to find all the values in the string. So if it was 10.00 it would find every value that is 10.05 or less. I would assume that some sort of regex would involved to find the values and then I could put them in an array then sort them.

So it would be something like this to find the which of those values fit my criteria.

int [] array;
int arraysize;
int lowvalue;
int total;

for(int i = 0; i<arraysize; ++i)
{
    if(array[i] == lowvalue*1.05) ++total;
}

My problem is getting those values in the array. I have read this but d+ does not really work with floating points.

  • 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-23T20:42:33+00:00Added an answer on May 23, 2026 at 8:42 pm

    You should use RegEx:

    Regex r = new RegEx("[0-9]+\.[0-9]+");
    Match m = r.Match(myString);
    

    Something like that. Then you can just use:

    float f = float.Parse(m.value);
    

    If you need an array:

    MatchCollection mc = r.Matches(myString);
    string[] myArray = new string[mc.Count];
    mc.CopyTo(myArray, 0);
    

    EDIT

    I just created a small sample application for you Joe. I compiled it and it worked fine on my machine using the input line from your question. If you are having problems, post your InputString so I can try it out with that. Here is the code I wrote:

    static void Main(string[] args)
    {
        const string InputString = "Item X $4.50 Description of item \r\n\r\n Item Z $4.75";
    
        var r = new Regex(@"[0-9]+\.[0-9]+");
        var mc = r.Matches(InputString);
        var matches = new Match[mc.Count];
        mc.CopyTo(matches, 0);
    
        var myFloats = new float[matches.Length];
        var ndx = 0;
        foreach (Match m in matches)
        {
            myFloats[ndx] = float.Parse(m.Value);
            ndx++;
        }
    
        foreach (float f in myFloats)
            Console.WriteLine(f.ToString());
    
        // myFloats should now have all your floating point values
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that has a large string key (varchar(1024)) that I was
if I have a large javascript string array that has over 10,000 elements, how
I have a arbitrarily large string of text from the user that needs to
I have a large mathematical expression that has to be created dynamically. For example,
I have a large hexidecimal (16 byte, 32 hex digits) data item that always
I have a function that has to accept an array of points, or an
I have come across a large issue that i am having that has suddenly
We have a large-ish query here that has several params, and for each one,
I have an app that needs to handle very large strings between a SQL
I have a Spring Web MVC application that I'd like to serve a large,

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.