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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:31:57+00:00 2026-05-31T22:31:57+00:00

I use regexes just often enough to be dangerous. I sometimes am hacking with

  • 0

I use regexes just often enough to be dangerous. I sometimes am hacking with grep and have a finite set of possible strings to match and will need to come up with a regex that will accept these but not another finite set of strings. Is there a tool that will suggest some regexes that can solve my problem? I know the general case is hard, but often I have finite enumerated lists and do not need the “best” regex, just a good enough one.

For example:
accept_list={‘bog’, ‘fog’, ‘frog’}
reject_list ={‘ogle’, ‘bogle’, ‘ogre’}

could be solved by ‘og$’, where I am assuming that $ indicates the end of the string.
I am not picky about the type; POSIX or PERL flavors are fine.
Is this a hard problem in the finite case?

  • 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-31T22:31:58+00:00Added an answer on May 31, 2026 at 10:31 pm

    In the finite case this is very easy since regex includes alternation (or):

    grep '^\(bog\|fog\|frog\)$'
    

    For example accepts only the strings bog, fog, and frog, while rejecting all other strings.

    So, indeed, it is very easy to come up with a regular expression that accepts any finite language.

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

Sidebar

Related Questions

I'm trying to use regexes to match space-separated numbers. I can't find a precise
I have the following possible strings that I need to turn into arrays so
Any code I've seen that uses Regexes tends to use them as a black
I'm developing a XPCOM C++ component that have to use some RegExps functions Does
Use case: I've just entered insert mode, and typed some text. Now I want
I have several strings which look like the following: <some_text> TAG[<some_text>@11.22.33.44] <some_text> I want
I have a form generator that uses (perl compatible) regexes for ther backend validation.
I know people often get told off here for using regexes to fiddle with
I have to use regular expressions in a c# application and I try to
Apache and Node.js have something in common. The more I use Node.js, the more

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.