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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:10:19+00:00 2026-05-17T23:10:19+00:00

I am trying to generate regular expressions based on some known texts. I assumed

  • 0

I am trying to generate regular expressions based on some known texts. I assumed I could load the text into a tree structure and see what kind of a tree is generated but I have 1 issue which I can’t seem to figure out: I want cousins to be joined together.

For Example:

ZABCDEF
ZBCCEFG

would result in:

  A-B-    D-E-F
Z-     C-
  B-C-    E-F-G

I don’t want any sorting done as the goal is to match the text as is. Any hints would be most appreciated.

  • 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-17T23:10:20+00:00Added an answer on May 17, 2026 at 11:10 pm

    Would be easier to know what type of regular expression you wanted to make from that resulting tree you wrote, but I think a tree is a bit more than you would need for this.

    Assuming you want the values that are the same to be the anchors of the regular expression, then all you would need to do is track when the characters at a specific index in the strings are the same. This could be tracked with a few data types but the easiest one to explain would just be an array of boolean values (If all strings are not the same length then you would want the length of the boolean array to be the size of the second largest string, not the largest (Nothing will ever match its trailing characters). By default they are initialized to false, you could then loop through the given strings and when all the characters at an index are the same set the boolean value to true.

    Then to build up your regular expression using the characters that are the same across all strings you could check the boolean array to see if you can place a value directly into the expression or if you need to handle a choice between the different strings… Please note that this processing could also just be done inlined, there is no real need to track the data and process the strings a second time.

    If this is in the right direction, or if you can provide more information to send us in the right direction, I could come back and write a quick bit of code.

    edit: Just a bit of code to explain what I was saying

    string s1 = "ZABCDEF";
    string s2 = "ZBCCEFG";
    StringBuilder sb = new StringBuilder();
    
    for (int i = 0; i < s1.Length; ++i)
    {
        if (s1[i] == s2[i])
        {
            sb.Append(s1[i]);
            Console.WriteLine("  " + s1[i]);
        }
        else
        {
            sb.Append("[" + s1[i] + s2[i] + "]");
            Console.WriteLine(s1[i] + "   " + s2[i]);
        }
    }
    
    Console.WriteLine(sb);
    

    Outputs you diagram vertically as well as the resulting expression that would match either string.

      Z
    A   B
    B   C
      C
    D   E
    E   F
    F   G
    Z[AB][BC]C[DE][EF][FG]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate some code at runtime where I put in some boiler-plate
I'm trying to generate code coverage reports with EMMA using tests of which some
I'm trying to generate a Google Map based off of results from a database.
So I'm trying to generate a nested list in Python based on a width
I'm trying to generate semi-random subsets with some restrictions. Here are the variable descriptions
I am trying to generate java file from wsdlurl. some of them are working
While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal
I am trying to generate a report by querying 2 databases (Sybase) in classic
I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.
I'm trying to generate customized xml files from a template xml file in python.

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.