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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:04:01+00:00 2026-06-17T05:04:01+00:00

The following line is in the jQuery source code: // Used for matching numbers

  • 0

The following line is in the jQuery source code:

// Used for matching numbers
core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,

I am confused by the last vertical bar in the two non-capturing groups,

(?:\d*\.|) 

and

(?:[eE][\-+]?\d+|)

The regular expression /(a|b)/ matches a or b, so I wondered what /(a|b|)/ matches, and it seems to “match everything”, in other words

reg1 = /(a|b)/;
reg1.test('c'); // false
reg2 = /(a|b|)/;
reg2.test('c'); // true

What is going on?

  • 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-17T05:04:02+00:00Added an answer on June 17, 2026 at 5:04 am

    I’ll try to break this down into chunks:

    • [\-+]?: This matches a plus sign, a minus sign or neither.
    • (?:\d*\.|): This groups (the ?: makes it a non-capturing group) any number of digits followed by a dot or nothing at all.
    • \d+: This matches one or more consecutive digits.
    • (?:[eE][\-+]?\d+|): This groups a lowercase or uppercase “e”, possibly followed by a plus or a minus and all of that followed by digits. Or, nothing.

    (a|) looks for a first. If a doesn’t exist, it matches nothing. It’s a confusing way of writing (a)?.

    This regex is a little confusing. I’d re-write it like this:

    /[+-]?\d*\.?\d+(?:e[+-]?\d+)?/i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jQuery 1.5 in my open source project and following line is
I have the following jQuery code: $(document).ready(function(){ var ac_config = { source: autocomplete-delta.php, select:
I have the following line of jQuery but it seems like overkill to use
The following line of code causes a JScript object expected error in IE: hideElements.apply(window,
The following line of code <% invite.accepted ? { @going, @not_going = 'selected', ''
The following line of code generates the compile time error (PE19) There is no
The following line of code is causing me an Exception using (new INVU.API.CallContextStore()) {
The following line of code causes my program to break in a very strange
I have this code set up and everything works except the last line for
The following JQuery line lets me get passed validation but the serverside raises an

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.