Thanks for the reply Jeff.
That solution makes sense, but as you suggested, it's not very scalable.
The way we are using Flex, we allow users to input any number of regexes,
and it's very possible for a large number of regexes to overlap and cause
duplicate matches. I'm afraid this may just be a limitation of Flex, and
we may need to think of other solutions.
On 9/27/12 10:45 AM, "Jeff Phillips" <jmanis2@...> wrote:
>Depending on the number of possible duplicate matches you might look at
>using nested start conditions. So if you matched A you could enter start
>condition A pass the token back through the input and then see if you
>match B or C. So that if you then matched B you could enter start
>condition AB. Again Pass the token back into the input stream and see if
>you match C. Each start condition would need a terminal action in the
>event you didn't find any further matches. This should work for a small
>set of condition but it's not very scalable.
>On Sep 27, 2012, at 19:22, "Calvin Lin (callin)" <callin@...> wrote:
>> Hi there,
>> It's my understanding that flex resolves multiple matches by taking the
>>one matching the most text. I have also read the FAQ entry about Flex
>>not matching patterns in the ordered they are defined, but the solutions
>>offered aren't exactly what I'm looking for.
>> I'm wondering if there is a way to have flex give me back data about
>>all the matches it encountered on a single string before resolving the
>>multiple matches and choosing one. That is, say there are 3 regex
>>expressions A, B, and C, and my input string matches all 3 of them.
>>Regardless of which one flex chooses to return, I'd like to know somehow
>>that it matched A, B, and C. Is this possible? It would be awesome if I
>>could have flex write the rule number of each match to a variable that I
>>can then read from, or something like that.
>> I know you can use YY_USER_ACTION to specify code to execute prior to a
>>matched rule's action. But my understanding is that this is for after
>>the multiple matches are resolved and one is selected. What I'm hoping
>>to do is have code execute before the multiple matches are resolved.
>> The most ideal solution would be for flex to return the pattern that is
>>highest in order, but the solutions on this page
>>rns-in-the-same-order-that-I-defined-them_002e) don't fit what I need.
>>Adding '.*' only helps for resolving between 2 matches.
>> Any help would be appreciated!
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> Flex-help mailing list