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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:49:51+00:00 2026-06-14T20:49:51+00:00

I am having some trouble with my regex in javascript. I have the following

  • 0

I am having some trouble with my regex in javascript.
I have the following code, that I think should match, but it doesn’t.

var rgx = new RegExp("{\d+:(\d+)}");

if (rgx.test("{0:00000}") == true) {
    alert("match");
}
else
{
    alert("no match");
}

​I am unsure if I should use test() here. I really want to catch the group, in my regex but exec() seems to give me the same result.

So what am I 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-14T20:49:53+00:00Added an answer on June 14, 2026 at 8:49 pm

    The problem is that you need to escape the \ character in your regex:

    var rgx = new RegExp("{\\d+:(\\d+)}");
    

    Alternatively, you can use the literal syntax:

    var rgx = /{\d+:(\d+)}/;
    

    To capture the results, you should also use the .match function as opposed to test or exec. It will return null if it doesn’t match and an array of at least one element if it does match.

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

Sidebar

Related Questions

I'm having trouble with some Regex code while scraping YouTube playlist pages. It mostly
I'm getting better at regex, but I'm still having some trouble... I'm trying to
Having some trouble selecting class names with plain 'ol vanilla javascript: var email =
I am having some trouble writing a regex expression that will strip outer brackets
I'm trying to track some goals via regex and I'm having trouble getting them
Having some trouble with R's garbage collection, when passing objects to C++. We have
Having some trouble with what should be a very simple scenario. For example purposes,
I´m having some trouble retrieving a collection of strings in a projection: say that
I'm having some trouble translating my working C# regular expression into JavaScript's regular expression
I'm having some trouble writing a regex for a telephone numbers. (not too great

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.