SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,384
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    javascriptkit.com regex tester does not work for regular-expressions.info code

    If you go to http://www.regular-expressions.info/...ptexample.html, you'll find a site that tests regular expressions (regex).

    At this site, http://www.javascriptkit.com/javatutors/re3.shtml, you'll find a tutor for regex. Now take the code and string from this page and insert them into the above page; there will be no matches.

    For example, insert match(/\d+/g) or (/\d+/g) into the Regexp: field and enter the following into the Subject string: field: Peter has 8 dollars and Jane has 15

    There will be no matches. Shouldn't the match be 3044345454 as it says on the javascriptkit.com site?

    I am trying to replace double-quotes with nothing (remove double quotes from a string), and was confused when the above kept returning no matches.
    string = string.replace([\"]/g, "")

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by StevenHu View Post
    For example, insert match(/\d+/g) or (/\d+/g) into the Regexp: field and enter the following into the Subject string: field: Peter has 8 dollars and Jane has 15

    There will be no matches. Shouldn't the match be 3044345454 as it says on the javascriptkit.com site?
    The regular expression is not match(/\d+/g) or even (/\d+/g)
    The regular expression is not even /\d+/g

    The regular expression is \d+

    The /.../ forward slashes are used to delimit a regular expression, in a similar way that single or double quotes are used to delimit strings.
    The g on the end is a flag, that specifies that the regular expression should be applied globally across the entire string.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •