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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:24:18+00:00 2026-05-14T06:24:18+00:00

i have: \£\d+\.\d\d should find: £6.95 £16.95 etc + is one or more \.

  • 0

i have: \£\d+\.\d\d

should find: £6.95 £16.95 etc
+ is one or more
\. is the dot
\d is for a digit

am i wrong? 🙁


JavaScript for Greasemonkey

// ==UserScript==
// @name           CurConvertor
// @namespace      CurConvertor
// @description    noam smadja
// @include        http://www.zavvi.com/*
// ==/UserScript==
textNodes = document.evaluate(
                              "//text()",
                              document,
                              null,
                              XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
                              null);
var searchRE = /\£[0-9]\+.[0-9][0-9];
var replace = 'pling';
for (var i=0;i<textNodes.snapshotLength;i++) {
    var node = textNodes.snapshotItem(i);
    node.data = node.data.replace(searchRE, replace);
}

when i change the regex to /Free for example it finds and changes. but i guess i am missing something!

  • 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-14T06:24:18+00:00Added an answer on May 14, 2026 at 6:24 am

    Had this written up for your last question just before it was deleted.

    Here are the problems you’re having with your GM script.

    1. You’re checking absolutely every
      text node on the page for some
      reason. This isn’t causing it to
      break but it’s unnecessary and slow.
      It would be better to look for text
      nodes inside .price nodes and .rrp
      .strike nodes instead.

    2. When creating new regexp objects in
      this way, backslashes must be
      escaped, ex:

      var searchRE = new
      RegExp(‘\\d\\d’,’gi’);

      not

      var
      searchRE = new RegExp(‘\d\d’,’gi’);

      So you can add the backslashes, or
      create your regex like this:

      var
      searchRE = /\d\d/gi;

    3. Your actual regular expression is
      only checking for numbers like
      ##ANYCHARACTER##, and will ignore £5.00 and £128.24

    4. Your replacement needs to be either
      a string or a callback function, not
      a regular expression object.


    Putting it all together

    textNodes = document.evaluate(
                                  "//p[contains(@class,'price')]/text() | //p[contains(@class,'rrp')]/span[contains(@class,'strike')]/text()",
                                  document,
                                  null,
                                  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
                                  null);
    var searchRE = /£(\d+\.\d\d)/gi;
    var replace = function(str,p1){return "₪" + ( (p1*5.67).toFixed(2) );}
    
    for (var i=0,l=textNodes.snapshotLength;i<l;i++) {
        var node = textNodes.snapshotItem(i);
        node.data = node.data.replace(searchRE, replace);
    }
    

    Changes:

    • Xpath now includes only p.price and p.rrp span.strke nodes
    • Search regular expression created with /regex/ instead of new RegExp
    • Search variable now includes target currency symbol
    • Replace variable is now a function that replaces the currency symbol with a new symbol, and multiplies the first matched substring with substring * 5.67
    • for loop sets a variable to the snapshot length at the beginning of the loop, instead of checking textNodes.snapshotLength at the beginning of every loop.

    Hope that helps!

    [edit]Some of these points don’t apply, as the original question changed a few times, but the final script is relevant, and the points may still be of interest to you for why your script was failing originally.

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

Sidebar

Related Questions

SUMMARY: I have an application which consumes way more memory that it should (roughly
I have the following application_controller method: def current_account @current_account ||= Account.find_by_subdomain(request.subdomain) end Should I
I have a UIButton that should have 2 statuses - Play and Pause; i.e.
UPDATE: I should have mentioned in the original post that I want to learn
CGI scripts should have access to a list of environment variables set by the
My Thumbnails should have some shadows, I'd like to do this with some absolutely
Scala programmer should have known that this sort of writing : class Person{ var
I have what should be a simple issue: On my newest rendition of http://www.derekbeck.com/1775
I have a text file with text that should have been interpreted as utf-8
All Gmail users should have already noticed that file upload progress bar has been

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.