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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:48:39+00:00 2026-05-17T16:48:39+00:00

As the name suggests we may think that regular expressions can match regular languages

  • 0

As the name suggests we may think that regular expressions can match regular languages only. But regular expressions we use in practice contain stuff that I am not sure it’s possible to implement with their theoretical counterparts. How for example would you simulate a back-reference?
So the question arises: what is the theoretical power of the regular expressions we use in practice? Can you think of a way to match {(a^n)(b^n)|n>=0}? What about {(a^n)(b^n)(c^n)|n>=0}?

  • 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-17T16:48:39+00:00Added an answer on May 17, 2026 at 4:48 pm

    The answer to your question is, “regular expression” languages that allow back-references are neither regular nor context-free. (In other words, as you pointed out, you cannot simulate back-reference with a regular language, nor with a CFL.) In fact, Wikipedia says many of the “regular expression” languages we use in practice are NP-Complete:

    Pattern matching with an unbounded
    number of back references, as
    supported by numerous modern tools, is
    NP-complete (see,[11] Theorem 6.2).

    As others have suggested, the regular expression languages commonly supported in computer languages and libraries are a different animal from regular expressions in formal language theory. Larry Wall wrote in regard to Perl “regexes,”

    ‘Regular expressions’ […] are only
    marginally related to real regular
    expressions. Nevertheless, the term
    has grown with the capabilities of our
    pattern matching engines, so I’m not
    going to try to fight linguistic
    necessity here. I will, however,
    generally call them “regexes”

    You asked,

    Can you think of a way to match
    {(a^n)(b^n)|n>=0}? What about
    {(a^n)(b^n)(c^n)|n>=0}?

    I’m not sure here if you’re trying to test whether theoretical regular expression languages can match the “language of squares”, or whether you’re looking for an implementation in a (practical) regex language. Here’s the proof why the former is not possible; and here’s a long explanation and implementation of the latter for java regexes.

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

Sidebar

Related Questions

I am very confused by the name 'unordered_map'. The name suggests that the keys
I want to check a name using regular expression, but I'm not getting convincing
May be obvious but I tried searching and can't figure it out. I am
I have a class CollectionOfThings . As its name suggests its a simple collection
Name: <%= Html.TextBox(txtName, 20, new { @class = hello }) %> I want that
SELECT name FROM sys.databases -- this can list all database name in the server
As part of a project, I need to analyse string which may contain a
I'm trying to install dajax / dajaxice according to their documentation, which suggests that
I'm looking for a Java library that can do Named entity recognition (NER) with
The name says it all really. I suspect that insertion sort is best, since

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.