471,310 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Possilbe to get the index of which alternate matched in a RegExpr?


I have a regexpr that consist of a set of alternates, e.g:
(ABC|DEF|XYZ)

I need to know the index (0,1,2) of the alternate that matched. I can't find
anything about this (and I've googled it quite a lot!)

I'm reading a file and creating an indexed collections of objects when my
programs starts. One of the properties of each object is a match pattern. I
create the alternation string from these patterns, ansd instantiate a
RegExpr. The program then gets input from another source, and I pass each
line of input to the RegExpr. If the RegExpr matches, I need to know the
index of the alternation that matched, so I can use that to index back into
the collection and get more information about the object on that line of
input. Then I can further process that line based on what kind of object it
is.

TIA!
--
Bill Hertzing
Tools Development
ATAPTechnology, Inc.
Jun 27 '08 #1
1 1082
Hi Bill,

What you need is a MatchEvaluator. Here is an example:

http://msdn.microsoft.com/nl-be/libr...or(en-us).aspx

Regards,
Joachim
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jonas | last post: by
4 posts views Thread by MC | last post: by
25 posts views Thread by kapilk | last post: by
17 posts views Thread by clintonG | last post: by
11 posts views Thread by Chris | last post: by
7 posts views Thread by Henry J. | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.