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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:13:44+00:00 2026-05-22T12:13:44+00:00

I have this piece of VBNet code that i would like to translate into

  • 0

I have this piece of VBNet code that i would like to translate into javascript:

  Dim phone_check_pattern = "^(\+?|(\(\+?[0-9]{1,3}\))|)([ 0-9.//-]|\([ 0-9.//-]+\))+((x|X|((e|E)(x|X)(t|T)))([ 0-9.//-]|\([ 0-9.//-]+\)))?$"
    System.Diagnostics.Debug.WriteLine(System.Text.RegularExpressions.Regex.IsMatch("test input", phone_check_pattern))

my translated result:

var phone_check_pattern = "^(\+?|(\(\+?[0-9]{1,3}\))|)([ 0-9.//-]|\([ 0-9.//-]+\))+((x|X|((e|E)(x|X)(t|T)))([ 0-9.//-]|\([ 0-9.//-]+\)))?$";
alert(new RegExp(phone_check_pattern).test("test input"))

However when i run it it has error Uncaught SyntaxError: Invalid regular expression:: Nothing to repeat

(my VbNet code doesn’t have any error though)

Does anyone know what’s causing the problem?

  • 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-22T12:13:45+00:00Added an answer on May 22, 2026 at 12:13 pm

    The backslash character in JavaScript strings is an escape character, so the backslashes you have in your string are escaping the next character for the string, not for the regular expression. So right near the beginning, in your "^(\+?, the backslash there just escapes the + for the string (which it doesn’t need), and what the regexp sees is just a raw + with nothing to repeat. Hence the error.

    Fortunately, JavaScript has a literal syntax for regular expressions (delimited with / characters), which would probably be a better starting point for you:

    var re = /^(\+?|(\(\+?[0-9]{1,3}\))|)([ 0-9.\/-]|\([ 0-9.\/-]+\))+((x|X|((e|E)(x|X)(t|T)))([ 0-9.\/-]|\([ 0-9.\/-]+\)))?$/;
    alert(re.test("test input"));
    

    Then at least the backslashes are escaping in the regex, not the string. (Note that since / is the delimiter for the regular expression literal, we have to escape it (with a backslash).)

    I haven’t exhaustively reviewed the actual regexp, but that should get you started.

    More about regular expression literals in the spec, of course, and here on MDC.

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

Sidebar

Related Questions

I have a piece of Vb.net code that finds the nunit.exe process like this:
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
I have this piece of code that works fine in subsonic 2.2, I migrated
I have this piece of code, that it refuses to work without the !important
I have this piece of Jquery code that grabs a heading in a table
I have this piece of code that loops through an array and load images
I have this piece of code that works very well and gives me the
I have this piece of code: while(fileStream>>help) { MyVector.push_back(help); } ...and lets say that
I have this piece of Boost code that iterates through files in a directory:
I am using iTextSharp in VB.net. I have this piece of code from java

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.