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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:28:52+00:00 2026-05-25T23:28:52+00:00

I want to test a string’s format. This string should start with a +

  • 0

I want to test a string’s format. This string should start with a + sign, then 2 digits, then a . sign, then 10 digits.

/^\+\d{2}\.\d{10}$/.test('+34.2398320186');

This way, it works (you can test it). But when I use RegExp, it says that the syntax has invalid quantifier error. What’s 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-05-25T23:28:53+00:00Added an answer on May 25, 2026 at 11:28 pm

    You have to escape the \ with a second \\

    new RegExp('^\\+\\d{2}\\.\\d{10}$'); // should work
    

    I’ll add a recommendation from http://www.regular-expressions.info/javascript.html

    I recommend that you do not use the RegExp constructor with a literal
    string, because in literal strings, backslashes must be escaped.

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

Sidebar

Related Questions

I have a string of test like this: <customtag>hey</customtag> I want to use a
I have a test string which is something like this: digit{digit}digit I want to
Possible Duplicate: Efficient way to test string for certain words I want to check
What I want is pretty simple. Given a string 'this is my test string,'
I want to test whether a certain string is contained in a short list
I want to test whether two languages have a string in common. Both of
Let's say I declare a variable: String a = test; And I want to
I want to test a string to see it contains certain words. i.e: $string
this is a test string transparent url(http://www.google.com/chart?chs=630x100&cht=bvs&chxt=x&chxl=0:%7C1840%7C1860%7C1880%7C1900%7C1920%7C1940%7C1960%7C1980%7C2000%7C&chxr=0,0,100&chxs=0,676767,11.3000002,0,tl,676767,676767&chd=e:D9AACPFjGWAAGDLfCeFgBvHLLSCZGED5GOKwDKCxJmF2FwFfERFwEZGcEJHlENJDJ9I0HQDjE-MAK2J9NMI9IAFtNaIOKtGoG2IYKBFvLEJmMLHdIFHXG.IPHrK2I9ULROI8SfHRFTeCIrQPOwXgPHVxQkbCbhg8iDwIvKkety..AAAAAAAA&chbh=7,0,0&chg=11.11,0,5,6&chxp=0,0.0,11.1,22.2,33.3,44.4,55.6,66.7,77.8,88.9&chco=3366cc,bbcced&chm=R,bbbbbb,0,0.9954,1.0%7Ch,bbbbbb,0,1.0,1.0,1&chxs=0,000000,11,-1&hl=en) i want to extract all the data
I have created a method where I can search for string placeholders, this 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.