You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to generate counter-examples to a regex pattern? This would be incredibly useful for writing tests for format validators. Think validates_format_of for shoulda-matchers.
Conceptually, it would enumerate all strings that don't match the pattern.
it seems like this is computationally possible at least. the complement of a regular language is also regular, which means that you can enumerate the counter-examples by "negating" the regular expression's deterministic finite automaton representation, and then enumerating examples from that.
...But what does a negated /hello/ actually look like? Without using irregular aspects of regex (i.e. look-arounds), that is. I suspect this may closely relate to this problem I encountered with the absence operator.
Is there a way to generate counter-examples to a regex pattern? This would be incredibly useful for writing tests for format validators. Think
validates_format_of
for shoulda-matchers.Conceptually, it would enumerate all strings that don't match the pattern.
Ideal behavior:
it seems like this is computationally possible at least. the complement of a regular language is also regular, which means that you can enumerate the counter-examples by "negating" the regular expression's deterministic finite automaton representation, and then enumerating examples from that.
https://math.stackexchange.com/questions/685182/complement-of-a-regular-expression
The text was updated successfully, but these errors were encountered: