Live data from Hacker News

Calculate the difference and intersection of any two regexes

phylactery.org

1–10 of 127 posts

Re: Calculate the difference and intersection of any two regexes

#4
post #2

The amazing page computes binary relations between pairs of regular expressions and shows a graphical representation of the DFA. It’s a really incredible demonstration of some highly non-trivial operations on regular expressions.

It's very cool, but also no wonder that it doesn't support all those features of regexes which technically make them not regular expressions anymore. Though, I would have thought ^ and $ anchors shouldn't be a problem?

Re: Calculate the difference and intersection of any two regexes

#8
post #2

The amazing page computes binary relations between pairs of regular expressions and shows a graphical representation of the DFA. It’s a really incredible demonstration of some highly non-trivial operations on regular expressions.

It's very cool, but also no wonder that it doesn't support all those features of regexes which technically make them not regular expressions anymore. Though, I would have thought ^ and $ anchors shouldn't be a problem?

This page implements regex matching, not searching. So in effect, every pattern has an implicit ^ at the beginning and $ at the end.

Re: Calculate the difference and intersection of any two regexes

#9

Kinda related but I'm looking for something that could give me the number of possible matching strings for a simple regex. Does such a tool exist ?

I feel like it shouldn't be too hard to calculate from the finite automaton that encodes the regular expression, but surely in most cases it will simply be infinite?

Re: Calculate the difference and intersection of any two regexes

#10

Kinda related but I'm looking for something that could give me the number of possible matching strings for a simple regex. Does such a tool exist ?

The answer is usually an infinite number, except for very, very simple cases. Anything involving * for example means infinity is your answer.
Post reply on HN