top | item 40402986

Is there a regular expression to detect a valid regular expression? (2008)

30 points| WayToDoor | 1 year ago |stackoverflow.com

12 comments

order

d5ve|1 year ago

Damian Conway's https://metacpan.org/pod/PPR module defines a regex (in the commonly used sense) that can match perl source code - including perl regexes!

Edit: "The PPR module provides a single regular expression that defines a set of independent subpatterns suitable for matching entire Perl documents, as well as a wide range of individual syntactic components of Perl (i.e. statements, expressions, control blocks, variables, etc.)"

wyldfire|1 year ago

Oh man you've already got two problems? Maybe it's four now.

sargstuff|1 year ago

symantics vs. non-semantics. Perhaps examples/explainations of where regular expressions sit relative to grammars, grammar validation, syntax, and parsing might be helpful. [0][1][2][3][4]

[0] : https://web.mit.edu/6.005/www/fa15/classes/17-regex-grammars...

[1] : https://peerj.com/preprints/1248.pdf

[2] : https://www.cs.ox.ac.uk/ralf.hinze/WG2.8/28/slides/fritz-pap...

[3] : https://www.npmjs.com/package/regexp-tree

[4] : example bnf grammar for regular expressions : https://github.com/DmitrySoshnikov/regexp-tree/blob/master/s...

willcipriano|1 year ago

What about a regular expression that detects regular expressions that detect valid regular expressions?

bediger4000|1 year ago

The user ID that asked the question looks to have last answered a question in 2016.

I'm not sure what this means. Have we asked and answered all the good questions already?

a-dub|1 year ago

protip: a language is not regular if you need counter(s) to parse it.

protip 2: good regex implementations often have extensions that support counters.

verteu|1 year ago

Technically, the set of strings containing balanced parentheses is not a regular language...