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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:44:34+00:00 2026-06-12T03:44:34+00:00

I have a regular expression as such: var pat = new RegExp([0-9]{1}\.[0-9]{1}); I use

  • 0

I have a regular expression as such:

var pat = new RegExp("[0-9]{1}\.[0-9]{1}");

I use jQuery to get a number from a textbox as such:

var theValue = $(item).val();

I’ve been entering numbers and testing the regex with this line:

alert(pat.test(theValue));

If I enter the number .111 it passes. This should not be the case as the first digit has to be 0-9 followed by a period and then followed by another digit 0-9. I can’t see what I am doing wrong.

  • 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-12T03:44:35+00:00Added an answer on June 12, 2026 at 3:44 am

    To use in a string, you need to escape the \ in order for the backslash character to appear.

    var pat = new RegExp("[0-9]{1}\\.[0-9]{1}");
    

    A more concise, and perhaps more reliable form would be this:

    /[0-9]\.[0-9]/
    

    Assuming the pattern should match a single number followed by a period followed by another single number.

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

Sidebar

Related Questions

I have following regular expression: ^-?([0-9]{0,3}$|[0-9]{0,2}\.?[0-9]{0,1}$) It should not allow 4 digit number such
I have such a regular expression: re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.MULTILINE|re.UNICODE) But that doesn't include hashbangs (#!)
I have a regular expression as follows: ^/[a-z0-9]+$ This matches strings such as /hello
I have a regular expression with a backreference. How can use it in a
I have the following regular expression for eliminating spaces, tabs, and new lines: [^
I have never really used regular expressions all that much and as such i
I have a regular expression to validate the dates and it works fine, this
I have a regular expression which allows the value range '1111' - '999999', excluding
I have a regular expression which uses GroupCollection s in it's capture to capture
I have a regular expression to validate a input value. At this point I

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.