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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:20:04+00:00 2026-05-17T02:20:04+00:00

I was asked today if there was a library to take a list of

  • 0

I was asked today if there was a library to take a list of strings and to compute the most efficient regex to match only those strings. I think it’s an NP Complete problem by itself, but I think we can refine the scope a bit.

How would I generate and simplify a regex to match a subset of hosts from a larger set of all hosts on my network? (Knowing that I might not get the most efficient regex.)

The first step is easy. From the following list;

  • appserver1.domain.tld
  • appserver2.domain.tld
  • appserver3.domain.tld

I can concatenate and escape them into

appserver1\.domain\.tld|appserver2\.domain\.tld|appserver3\.domain\.tld

And I know how to manually simplify the regex into

appserver[123]\.domain\.tld

From there I can test that pattern against the full list of hosts and verify that it only matches the selected 3 hosts. What I don’t know is how to automate the simplifying process. Are there any libraries (in Perl, Javascript or C#) or common practices?

Thanks

Update I got some awesome perl modules but I would love a front end solution as well. That means Javascript. I’ve searched around but nobody has ported the perl modules to JS and I’m unsuccessful in finding the language to search for this type of library.

  • 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-17T02:20:04+00:00Added an answer on May 17, 2026 at 2:20 am

    Regexp::Assemble::Compressed / Regexp::Assemble know far more tricks than PreSuf. R::A comes with the command-line tool assemble (not installed by default) which makes building regexes even easier.

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

Sidebar

Related Questions

This is related to my question asked here today on SO. Is there a
I asked a question earlier today, but I think I need to approach it
Interviewer asked me about this today ...is there an answer ?
I have been asked this question today. When debugging, there is an error. But
A developer asked me today if there are disadvantages or risks while setting all
I was asked today to list all image files references in our project to
Today I had an interview there they asked me can we include .c file
Earlier today I asked similar problem to find the maximum element which is common
I was asked this question today by a colleague, and couldn't find any clue
I asked a question earlier today ( Methods of Managing Source Code ) as

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.