From: Robert Klemme Date: 2006-03-12T21:13:44+09:00 Subject: Re: Regular Expression Intersection Benjohn Barnes wrote: > On 12 Mar 2006, at 09:58, Dan Kohn wrote: > >> You'll generally get a better answer if you include an example in >> your question. Also, that link didn't work. >> >> If you're asking how to apply two regexps, you can use the scan >> method to get the results in arrays, and then intersect them with &. This does not help at all as Benjon explains. The question is not whether there are some strings in a set of strings that are matched by both RX but whether there is at least one string among *all* possible strings that is matched by both. >> string ="hello world"; puts string.scan(/.../) & string.scan(/..l/) > > I think he's trying to do this... > > If you have a regular expression, R, then there is a (potentially > infinite) set S(R) of input strings that it will match. > > Given two regular expressions, R1 and R2, you can find the strings > that match either regular expression: > S(R1) & S(R2) > > He now wants to find a regular expression Ri such that: > S(Ri) = S(R1) & S(R2) No. He wants to know whether S(R1) & S(R2) is not empty. At least that's what he stated. You might be able to solve the problem by finding Ri but that was not the original problem stated. Kind regards robert