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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:52:08+00:00 2026-05-23T17:52:08+00:00

I have the following option text that I want to put into a variable

  • 0

I have the following option text that I want to put into a variable plus remove all characters except the value after the £ then convert it to a number. In this case 28.00

<option value="294">Set of 2 Boots</option><option value="295">Set of 4 Boots[Add £28.00]</option>

This converts the selects options text correctly.

recal_var = jQuery('select').find('option:selected').text();

But this doesn’t seem to work with the £ symbol. If i change everything to a $ symbol I have no problems

price_result = parseFloat(recal_var.split('[Add £')[1].slice(0,-1).replace(/,/g,''));

I have also tried these as well with no luck.

price_result = parseFloat(recal_var.split('[Add &#163;')[1].slice(0,-1).replace(/,/g,''));

price_result = parseFloat(recal_var.split('[Add &pound;')[1].slice(0,-1).replace(/,/g,''));

What I get in firebug is recal_var.split(“[Add \uFFFD”)[1] is undefined

page has this metatag, not sure if that makes a difference.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  • 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-23T17:52:08+00:00Added an answer on May 23, 2026 at 5:52 pm
    var str = "Set of 4 Boots[Add £28.00]";
    var costStr = str.match(/£([\d.]+)/);
    if(costStr){
        var cost = parseFloat(costStr[1]);
        alert(cost);
    }
    

    Example: jsbin

    EDIT ignoring the £ and relying on position at end:

    var str = "Set of 4 Boots[Add £28.00]";
    var costStr = str.match(/([\d.]+)\]$/);
    if(costStr){
        var cost = parseFloat(costStr[1]);
        alert(cost);
    }
    

    To match comma

    var str = "Set of 4 Boots[Add £28,133.00]";
    var costStr = str.match(/([\d.,]+)\]$/);
    if(costStr){
        var cost = parseFloat(costStr[1].replace(/,/g,""));
        alert(cost);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following PowerShell loop: Set-Variable -Name YELLOW -Option ReadOnly -Value 0 Set-Variable
I have the following: <select name=dayRange class=styled> <option value=0>All day</option> <option value=1>Morning and day
I have the following code in html: <select> <option text=item9 value=9></option> <option text=item10 value=10></option>
i have following filteringselect: <select name=v dojoType=dijit.form.FilteringSelect valueList=v id=v value=0><option value=></option><option value=0>0-test</option><option value=1>1-test2/option><option value=2>2-test3</option><option
I have the following drop down list: <select name=selSS1 id=select_value> <option value=val0>sea zero</option> <option
I do have the following JavaScript. <form> <select id=sel> <option value=1>item_1</option> <option value=2>item_2</option> <option
I have a controller that generates the following json data: [ { title: Option
I'm trying to do the following: I have an input <input type=text value=red,yellow,blue id=colors
I have a text file which has the following structure: 341|18 Hello world|20090225230048AAnhStI|90|$0.30|10|289|2|2|2|Is that
I have the following jQuery code which runs when I'm clicking an option in

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.