0

The template of the function is as follows:

func GetIntersection(firstRegex string, secondRegex string) string {
    ...
}

I'm trying to use Ragel to get the intersection of two regular expressions. Not sure if Ragel is the right tool to use, though. My last resort is implementing conversions from regex to DFA and DFA to regex, as well as intersection of two DFA's myself, but I would rather avoid that. Would highly appreciate any reliable libraries to solve the problem.

aygestan
  • 73
  • 1
  • 8
  • Is the _intersection_ a tall task for software ? –  Jun 20 '19 at 00:41
  • @sln not sure what you mean. As far as I can tell, some languages support character class intersection natively, however, apparently Golang is not one of them and that is not quite what I need. I have discovered that it should be theoretically possible to compute the intersection of two simple regular expressions efficiently (by intersection I mean a regular expression that describes the intersection of the sets of strings that match the two regular expressions), but I was unable to find a library suitable to my needs. – aygestan Jun 20 '19 at 16:10

1 Answers1

2

Ragel has an intersection operator (&). You can produce the intersection of any two regular expressions, so long as they are expressed in the ragel syntax. There is no freely available automatic ragel-to-regex translation. This is the kind of thing I've been producing for clients privately. Anyhow, see the manual for more information on intersection.