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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:09:53+00:00 2026-05-24T17:09:53+00:00

Friends its possible to create javascript dynamic regex at runtime. i create this regex:

  • 0

Friends its possible to create javascript dynamic regex at runtime. i create this regex:

[+]?\(?800\)?[+ .]?123?[+ .]?1234

for this 800.123.1234 number. This regex can found/accept this number on page in any format
like:

(800).123.1234
+(800)1231234
+(800)1231234
(800).123.1234
800.123.1234
800.123.1234

Its work fine but i need to create rejex dynamic depends on any number that i feed in input text field. here is my working code example:
http://jsfiddle.net/webdesignerart/ShbMv/

means if two numbers i have on page
800.123.1234 and 855.455.4577
i add this 855.455.4577 number to input text field
then regex have to create dynamic or parse

[+]?\(?800\)?[+ .]?123?[+ .]?1234

in this regex to find this 855.455.4577.

  • 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-24T17:09:54+00:00Added an answer on May 24, 2026 at 5:09 pm

    You can create your own regular expression object anytime using the new RegExp(str) syntax.

    var str = "[+]?\\(?800\\)?[+ .]?123?[+ .]?1234";
    var re = new RegExp(str);
    re.exec("800.123.1234");
    

    Note, you may need double backslashes on some declarations in order to allow a single backslash to survive into the regular expression constructor.

    But, if I really understood what you were doing, there is probably a single regular expression that can be created in advance that will match what you need to match. For example, you could match all the phone numbers you have in your list with this:

    \+?\(?\d\d\d\)?\.?\d\d\d\.?\d\d\d\d
    
    zero or one plus sign
    zero or one left paren
    3 digits
    zero or one right paren
    zero or one period
    three digits
    zero or one period
    four digits
    

    Here’s a jsFiddle that tests all your test numbers against a regular expression and extracts just the numbers out of each form to make a normalize phone number form: http://jsfiddle.net/jfriend00/43mqV/. It uses this regular expression:

    \+?\(?(\d\d\d)\)?\.?(\d\d\d)\.?(\d\d\d\d)
    

    This is the same as above, but it also captures each group of numbers so we can pick out just the numbers from the matched results.

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

Sidebar

Related Questions

I know it's possible to create a friend function in C++: class box {
Friends its really giving me a great head ache about the problem I am
Possible Duplicate: Is it a good idea to learn JavaScript before learning jQuery? I
Can I access My own Database(on my server) using Facebook API's or its just
Possible Duplicates: ‘Friends’ equivalent for Java? Is there a way to simulate the C++
I'm wondering if its possible to join together IEnumerable's. Basically I have a bunch
I'm trying to create an assert method in Javascript. I've been struggling with arguments.callee.caller
I am using facebook registration plugin and wanted to see if its possible to
I talked to a friend of mine and he told me that it's possible
The C++ friend keyword allows a class A to designate class B as its

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.