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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:55:19+00:00 2026-05-10T23:55:19+00:00

The monthRegex regular expression always returns true, even if dateInput is something like December

  • 0

The monthRegex regular expression always returns true, even if dateInput is something like ‘December 1, 2008’ by my thoughts it should match a regular expression by whichever key I pass into it. But that isn’t what happens, it just returns true, and detects ‘JAN’ as the month.

    function dateFormat(dateInput) {      var formattedDate = '';      var the_date, month, year;      var monthHash = new Array();     monthHash['JAN']='01';     monthHash['FEB']='02';     monthHash['MAR']='03';     monthHash['APR']='04';     monthHash['MAY']='05';     monthHash['JUN']='06';     monthHash['JUL']='07';     monthHash['AUG']='08';     monthHash['SEP']='09';     monthHash['OCT']='10';     monthHash['NOV']='11';     monthHash['DEC']='12';      // Find which month we are dealing with     var whichKey = null;      for(var key in monthHash) {           var monthRegex = new RegExp(key, 'i')         monthRegex.compile();          console.log('monthRegex.compile: ' + monthRegex.test(dateInput));          if(monthRegex.test(dateInput))         {             whichKey = key;             break;         }     } } 

Thank you,
  Andrew J. Leer

  • 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. 2026-05-10T23:55:19+00:00Added an answer on May 10, 2026 at 11:55 pm

    Remove the ‘monthRegex.compile();’ line and it works.

    This is because monthRegex.compile(); complies ” as a regex and therefore everything matches it.

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

Sidebar

Related Questions

Setup, php + mongodb. The database should contain multiple items where 'Title' contains both
i have a mongo collection like this: { A2_AboutMe: , A2_Attributes: |av|nv|, A2_Birthday: ,
I would like to write a query in Doctrine Mongo ODM that searches by
I'm trying to use regular expressions to query Mongodb using Doctrine's Mongodb ODM on
What I would like to do is the following. $collection = $this->db->products_sale; $user_query =
Has anyone have any idea how to use MongoRegex for the document search? I
I got these documents: users -> id, name, friendList (_id, name), createdOn I have
I am moving some parts of a site from mysql to mongodb, and one
I am developing a search portal, so I need to find the searched text
--> Please see updates at the bottom, I have replicated the same issue 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.