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

  • Home
  • SEARCH
  • 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 9171625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:11:18+00:00 2026-06-17T16:11:18+00:00

I have a string in which the data is getting loaded in this format.

  • 0

I have a string in which the data is getting loaded in this format. “float;#123456.0300000” from which i need to extract only 123456.03 and trim all other starting and ending characters. May be it is very basic that i am missing, please let me know how can i do that. Thanks.

  • 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-06-17T16:11:19+00:00Added an answer on June 17, 2026 at 4:11 pm

    If the format is always float;# followed by the bit you want, then it’s fairly simple:

    // TODO: Validate that it actually starts with "float;#". What do you want
    // to do if it doesn't?
    string userText = originalText.Substring("float;#".Length);
    // We wouldn't want to trim "300" to "3"
    if (userText.Contains("."))
    {
        userText = userText.TrimEnd('0');
        // Trim "123.000" to "123" instead of "123."
        if (userText.EndsWith("."))
        {
            userText = userText.Substring(0, userText.Length - 1);
        }
    }
    

    But you really need to be confident in the format – that there won’t be anything else you need to remove, etc.

    In particular:

    • What’s the maximum number of decimal places you want to support?
    • Might there be thousands separators?
    • Will the decimal separator always be a period?
    • Can the value be negative?
    • Is an explicit leading + valid?
    • Do you need to handle scientific format (1.234e5 etc)?
    • Might there be trailing characters?
    • Might the trailing characters include digits?
    • Do you need to handle non-ASCII digits?

    You may well want to use a regular expression if you need anything more complicated than the code above, but you’ll really want to know as much as you can about your possible inputs before going much further. (I’d strongly recommend writing unit tests for every form of input you can think of.)

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

Sidebar

Related Questions

I am getting JSON string from website. I have data which looks like this
I have a string data which I need to parse into a dictionary object.
I have a string which contains binary data ( non-text data ). How do
I have a string say string s =C:\\Data , I have an array which
I have to work with strings which may contain Lat/Long data, like this: $query
I have a structure which aims at storing user defined data (i.e. from a
I have a string which is in the following format, When there is a
I have a string which I need to pass to a function like below.
I have a new rails app which needs to access data from a legacy
I have XML data as a string which has to parsed, I am converting

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.