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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:31:29+00:00 2026-05-20T10:31:29+00:00

How do I extract the numbers out of a string like this: $1.50 Everything

  • 0

How do I extract the numbers out of a string like this:

$1.50

Everything but the currency symbol. Or from something like this:

rofl1.50lmao

Just asking if there’s an existing function that I’m not a aware of.

  • 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-20T10:31:30+00:00Added an answer on May 20, 2026 at 10:31 am

    This is “plain” JavaScript, but FWIW:

    justNumsAndDots = "rofl1.50lmao".replace(/[^\d.]/g,"") // -> "1.50" (string)
    asIntegral = parseInt("0" + justNumsAndDots, 10)       // -> 1 (number)
    asNumber = parseFloat("0" + justNumsAndDots)           // -> 1.5 (number)
    asTwoDecimalPlaces = (2 + asNumber).toFixed(2)         // -> "3.50" (string)
    

    Notes:

    1. Doesn’t take localization into account.
    2. Radix (base-10) is passed to parseInt to avoid potential octal conversion (not sure if this “issue” plagues AS).
    3. “0” is added to the start of justNumsAndDots so parseInt/parseFloat will never return a NaN here. (e.g. parseFloat(".") -> NaN, parseFloat("0.") -> 0). If NaN’s are desired, alter to suite.
    4. Input like “rofl1.chopter50lolz” will be stripped to “1.50”, it might be over-greedy, depending.
    5. Adapt to AS as necessary.

    Happy coding.

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

Sidebar

Related Questions

I need to extract the text (characters and numbers) from a multiline string. Everything
I have a string (char) and I want to extract numbers out of it.
I just want a very handy way to extract the numbers out of a
I have a File having text and few numbers.I just want to extract numbers
I'm using re.findall() to extract some version numbers from an HTML file: >>> import
I want to extract valid(on the basis of format) mobile numbers from a text.
Extract the number after #/ from my string: abcdefg#/123 .
I'm trying to extract not just the browser and its version number but also
what's the quickest way to extract a 5 digit number from a string in
I have a model like this: public PurchaseOrder { [Required] [StringLength(15)] public virtual string

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.