Duplicate of http://stackoverflow.com/questions/362793/regexp-that-matches-valid-regexps
How do you produce a regex that matches only valid regex?
For instance: "[hc]at"
would be valid (matching "hat"
and "cat"
), but "[hcat"
would be invalid, as it is missing ]
.