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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:00:06+00:00 2026-05-17T00:00:06+00:00

Given a sub-string, is there a way to generate all the possible regular expressions

  • 0

Given a sub-string, is there a way to generate all the possible regular expressions (most restrictive to least restrictive) that would match that sub-string for a given string?

For example, say you have a sub-string “orange” and a string “apple banana orange grape”. How would I get a list of regexes that match “orange” (I know there will be a lot; hoping there is some library to do this for me already).

  • 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-17T00:00:06+00:00Added an answer on May 17, 2026 at 12:00 am

    This is basically the same as asking “given some runtime requirements, is there a way to generate all the possible programs (most efficient to least efficient) that would match those requirements for a given input?” The answer is yes, there is a way to do it, but the number of the results is infinite, limited only by the bounds of reasonable memory and language implementation constraints, so you’ll need to impose restrictions on what constitutes a valid “program” for your purposes, in order to cut it down to a finite set.

    For instance, you can restrict yourself to a specific grammar, of sorts, representing a subset of the regular expression language in question, and only generate regexes matching that grammar:

    Regex       ::= StartAnchor? Anything? (Substring | Anything) Anything? EndAnchor?
    
    StartAnchor ::= "^"
    
    Anything    ::= ".*"
                  | "(.*)"
    
    Substring   ::= "orange"
                  | "(orange)"
    
    EndAnchor   ::= "$"
    
    

    Recursively take all paths of this grammar (i.e., each branch indicated by ? and |) to generate all of your target regular expressions. Of course, this answer deliberately says nothing about whether doing this is a good idea, or at all necessary…

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

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer C++03 14.3.2 Template non-type arguments A template-argument for a non-type,… May 17, 2026 at 2:04 am
  • Editorial Team
    Editorial Team added an answer Yes, this IE9 Beta bug has been reported to Microsoft… May 17, 2026 at 2:04 am
  • Editorial Team
    Editorial Team added an answer jQuery doesn't parse XML. You can use the following simple… May 17, 2026 at 2:04 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Im looking for an elegant way in Scala to split a given string into
I would like to generate a pdf file when the user clicks on it,
I read this question here: Is there a way to override the empty constructor
Given an input string (such as D4C3B2A1) I want to sort the alphabet characters,
I'm looking for a Perl string checksum function with the following properties: Input: Unicode
I have a combobox that passes along values in text, but they can have
Given this table: CREATE TABLE [Comments] ( [Id] [int] IDENTITY(1, 1) NOT NULL, [Text]
One way I found is to check if the Perl Debugger is loaded by
Given a table: |Name | Hobbies | ----------------------------------- |Joe | Eating,Running,Golf | |Dafydd |
It's a pretty common algorithm in command line parsing . Given a set of

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.