Validating regexp

MRAB python at mrabarnett.plus.com
Tue Aug 8 12:56:23 EDT 2017


On 2017-08-08 17:37, Larry Martell wrote:
> Anyone have any code or know of any packages for validating a regexp?
> 
> I have an app that allows users to enter regexps for db searching.
> When a user enters an invalid one (e.g. 'A|B|' is one I just saw) it
> causes downstream issues. I'd like to flag it at entry time.
> 
Couldn't you just try compile the regex and catch any exception?

Also, in that way is 'A|B|' invalid?



More information about the Python-list mailing list