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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:14:55+00:00 2026-06-11T19:14:55+00:00

I am trying to do Regular Expression matching. I have all the functions written

  • 0

I am trying to do Regular Expression matching. I have all the functions written out, but they are not working as they should. From what I can tell, it has a problem when I try to compare a list.
For instance, “re_contains(a,a).” gives true (obviously), as does “re_contains(union(a,b),a).”

But as soon as I make it a list, it fails. “re_contains(seq(a,b), [a,b]).” returns false. Append should be going through all the possible combinations to find the match, but none of these functions work correctly. This makes me thing that perhaps I am missing a base case. But I think “re_contains(X, L) :- X == L.” should take care of it. I must be over looking something important here.

Here is my code:

re_contains(empty, []).

re_contains(X, L) :-
    X == L.

re_contains(seq(X, Y), L) :-
    append(L1, L2, L),
    re_contains(X, L1),
    re_contains(Y, L2). 

re_contains(union(X, _), L) :-
    re_contains(X, L).

re_contains(union(_, Y), L) :- 
    re_contains(Y, L).  

re_contains(kleene(X), L) :- 
    append([Car|L1], L2, L),
    re_contains(X, [Car|L1]),
    re_contains(kleene(X), L2).

re_contains(kleene(_),[]).
  • 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-11T19:14:57+00:00Added an answer on June 11, 2026 at 7:14 pm

    append/3 will split L, and both L1 and L2 will be lists.

    I would try to replace re_contains(X, L) :- X == L. with re_contains(X, [X]).

    After the change, re_contains(a,a). will fail.

    You are representing the sequence in different ways, and your matcher doesn’t provide for both. Actually, the only cases ‘working’ are not sequences.

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

Sidebar

Related Questions

I working with some regular expression matching and I'm trying to figure out how
I'm trying to do what should be a simple Regular Expression, where all I
Hey, I've been trying to figure out why this regular expression isn't matching correctly.
I'm trying to use a URL matching regular expression that I got from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
I am trying to write regular expression for this pattern: String word=113(112,9); It should
I'm trying to figure out a regular expression on Ruby 1.8.7 for removing the
I m just learning regular expression matching using javascript, and have a doubt regarding
I'm trying to write a regular expression for matching the following HTML. <span class=hidden_text>Some
So I am trying to figure out a Regular Expression and am having some
I'm trying to use the Daring Fireball Regular Expression for matching URLs in Java,

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.