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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:23:40+00:00 2026-06-13T01:23:40+00:00

I have a strange problem, at least one I’ve never come across. I have

  • 0

I have a strange problem, at least one I’ve never come across. I have a precondition where customers have simple regular expressions associated with labels. The labels are all they care about. What I would like to do is create a list of all possible numbers that would match each of these regular expressions. I would have logic that would warn me when the list is beyond a certain threshold.

Here is an example of the regular expression: 34.25.14.(227|228|229|230|243|244|245|246)

Lets say that these ip(s) are associated with ACME. Behind the scenes when the user selects ACME (in our UI), I’m filling out a filter object that contains all of those possible numbers and submitting them as an OR query to a highly specialized Vertica database.

I just can’t determine an elegant way of creating a list of numbers from said regular expressions.

The others aspect of this, is that the java code within another portion of the product is using those regular expressions to show ACME by using a java Pattern.compile(), which means the customer ‘could’ create a complex regular expression. I’ve only seen them, so far, use something simple as shown above.

Is there a method that will generate a list based on regular expression?

Thanks for your time.

  • 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-13T01:23:41+00:00Added an answer on June 13, 2026 at 1:23 am

    Related:

    A library that generates data matching a regular expression (with limitations):
    http://code.google.com/p/xeger/

    Several solutions, such as conversing a regex into a grammar:
    Using Regex to generate Strings rather than match them


    EDIT: Actually, you can make it work!!! The only thing to address is to impose some domain-specific constraints to preclude combinatorial explosion like a+.

    If you add to the Xeger class something like this:

    public void enumerate() {
        System.out.println("enumerate: \"" + regex + "\"");
        int level = 0;
        String accumulated = "";
        enumerate(level, accumulated, automaton.getInitialState());
    }
    
    private void enumerate(int level, String accumulated, State state) {
        List<Transition> transitions = state.getSortedTransitions(true);
        if (state.isAccept()) {
            System.out.println(accumulated);
            return;
        }
        if (transitions.size() == 0) {
            assert state.isAccept();
            return;
        }
        int nroptions = state.isAccept() ? transitions.size() : transitions.size() - 1;
        for (int option = 0; option <= nroptions; option++) {
            // Moving on to next transition
            Transition transition = transitions.get(option - (state.isAccept() ? 1 : 0));
            for (char choice = transition.getMin(); choice <= transition.getMax(); choice++) {
                enumerate(level + 1, accumulated + choice, transition.getDest());
            }
        }
    }
    

    … and something like this to XegerTest:

    @Test
    public void enumerateAllVariants() {
        //String regex = "[ab]{4,6}c";
        String regex = "34\\.25\\.14\\.(227|228|229|230|243|244|245|246)";
        Xeger generator = new Xeger(regex);
        generator.enumerate();
    }
    

    … you will get this:

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running nl.flotsam.xeger.XegerTest
    enumerate: "34\.25\.14\.(227|228|229|230|243|244|245|246)"
    34.25.14.227
    34.25.14.228
    34.25.14.229
    34.25.14.243
    34.25.14.244
    34.25.14.245
    34.25.14.246
    34.25.14.230
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.114 sec
    

    … and, guess what. For “[ab]{4,6}c” it correctly produces 112 variants.

    It’s really a quick and dirty experiment, but it seems to work ;).

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

Sidebar

Related Questions

I have a strange problem on ipv6 connection. I write down a simple client
I have a strange problem happening on one page I am making: myDiv.append(<img src='...'
I have a bit of a strange problem with MySQL that I've never seen
Hallo, I have a quite strange problem in one of my C++ projects: I
I've just come across a pretty strange problem with VS2010 and Script#, which most
I have a strange problem, at least I think it is strange. The following
i have strange problem doing reporting: i have numerous clients with different issued invoices.
I have strange problem with receiving data from socket. On client im using air
I have a strange problem with IE. I have a sequence of forms on
I have a strange problem with in-app billing RESTORE_TRANSACTION command. Every request RESTORE_TRANSACTION request

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.