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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:09:19+00:00 2026-06-14T08:09:19+00:00

I was answering a question about regexes , when I noticed something weird. I

  • 0

I was answering a question about regexes, when I noticed something weird. I was testing regexes in RegexPal, and I was getting different results from what Chrome and Firefox were telling me.

The regex in question is: /^\d*(\.\d{1,2}$)?/.

In Firefox and Chrome: /^\d*(\.\d{1,2}$)?/.test('-1') returns true, but RegexPal says it doesn’t match.

http://regexpal.com/?flags=m&regex=%5E%5Cd%2A(%5C.%5Cd%7B1%2C2%7D%24)%3F&input=-1

My guess is that it has something to do with the fact that the regex matches nothing, by which I mean the empty string.

The regex matches the start of the string, then 0 numbers, then 0 of the group, so it would “match” -1, as it fits that mold, but the “match” would be “nothing” (empty string).

Why does RegexPal say it doesn’t match, but my web browsers say it does?

  • 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-14T08:09:20+00:00Added an answer on June 14, 2026 at 8:09 am

    RegexPal is working, but it’s just not obvious. The regex matches the empty string, so RegexPal highlights that for you.

    Well, since the empty string is empty, you can’t see that it’s highlighting it.

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

Sidebar

Related Questions

I was just answering a question about different approaches for picking the partition in
Answering another question about how const string data was stored in an executable a
After answering a question about how to force-free objects in Java (the guy was
In answering a question about a function that maps over multiple functions with the
While answering to a question about that here: https://stackoverflow.com/a/9872630/82609 I tried to do the
Before answering, it is not as easy question as you might have thought about
While answering this question, I got these confusing results: double d = 0.49999999999999990d; //output
I was answering a Question about how to show a directory structure on FTP
This question arose when I was working on answering another question about best practices
A related question about sorting may be relevant to answering this one. I've realized

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.