473,239 Members | 1,490 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 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 1163
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jonas | last post by:
Dear members, How can I use a function return value in a regexpr? $tmp=~s/mysearch/myfunction($1)/; sub myfunction { return $v; }
4
by: MC | last post by:
Hi, i'm trying to make a regexpr wether an ftp-input is valid or not. this is what i have: $var = "ftp://user:pass@localhost:21"; if ( $var =~ /^ftp:\/\/(*):(*)@(*):(.*)$/i ) { print...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
25
by: kapilk | last post by:
Sir, I know that the array index starts in C from 0 and not 1 can any body pls. tell me the reason. Is it because in the subscript i can have a unsigned integer and these start from 0 ...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
7
by: teddysnips | last post by:
Table DDL below: The tables I have contain Timesheet information. Each row in the tblTSCollected table contains an entry for an employee into the timesheet system, specifically by scanning the...
11
by: Chris | last post by:
I have a simple search feature that searches 3 fields in 3 separate tables in a MySQL db, and I'm getting an 'undefined index' error, but only in the first section (first table)of the results. The...
1
by: Daimz | last post by:
I am making a blog and as part of my template I am wanting to have my header and then another image on the side of that using the z-index: 2; to make it that layer about. so here is the css. ...
7
by: Henry J. | last post by:
I got a dumb question on the merge statement. I read the following example of merge statement at the IBM page:...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.