Is any regular expression to detect a valid regular expression ?

Is any regular expression to detect a valid regular expression ?

Asked on December 15, 2018 in Regex.
Add Comment


  • 2 Answer(s)

    Here is your solution:

    Incredible,

    check out a try..catch or everything your language provides.

    Answered on December 15, 2018.
    Add Comment

    Components:

    Never if you are strictly speaking about regular expressions and it not including some regular expression implementations that are actually context free grammars.

    In regex there is one limitation of regular expressions which makes it impossible to write a regex that matches all and only regexes. You cannot match implementations such as braces which are paired. Regexes use many such constructs, lets take [] as an example. Whenever there is an [ there must be a matching ]. Simple enough for a regex “[.*]”.

    And what makes it impossible for regexes is  nested. How  you will  write a regex which matches nested brackets? you cannot without an infinitely long regex. You can match any number of nested parens through brute force but you can’t ever match an arbitrarily long set of nested brackets.

    This capability is often referred to as counting  the depth of the nesting. In regex definition does not have the capability to count.

    Answered on December 15, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.