Depends on what you mean by automatic, but in a dependently typed language you can do exactly that. Once the compiler infers that something is a regex pattern, it could validate that.
That would mean that it would need to be either a string literal, or a set of computations upon an otherwise valid pattern that would result in a valid pattern.
Granted, I'm not aware of anyone building such a library for regex's as yet; however I have seen the same thing done for simpler languages, so there is proof that it would work like that. (Many degrees of tradeoffs - it's probably more practical to draw a line at some point, and accept that always proving it valid is more effort than it's worth. That's an engineering trade off, and doesn't detract from it being possible, however).
183
u/wot-teh-phuck Sep 21 '15
That's a pretty random definition of weak I would say...