473,487 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Regex Indexer Question.

I am trying to get the parts of a regular expression. This is a simplified
version of what I am trying to do.

expression:
((\w)+)

source:
something

results:
$1 = something
$2 = g

Is there any way to get an indexer for $2. For example $2.4 or $2(4) would
get me the fourth letter.
Nov 16 '05 #1
2 945
Wes
Hello Ben,

I don't think there is a way to do the indexing like you want. However you could always just capture the 4 char as a another cature group for example:

((\w\w\w(\w))+)

HTH
Wes Haggard
http://weblogs.asp.net/whaggard/

I am trying to get the parts of a regular expression. This is a
simplified version of what I am trying to do.

expression:
((\w)+)
source:
something
results:
$1 = something
$2 = g
Is there any way to get an indexer for $2. For example $2.4 or $2(4)
would get me the fourth letter.


Nov 16 '05 #2
"Ben Dewey" <As*********@hotmail.com> wrote in
news:O1**************@TK2MSFTNGP09.phx.gbl...
I am trying to get the parts of a regular expression. This is a simplified
version of what I am trying to do.

expression:
((\w)+)

source:
something

results:
$1 = something
$2 = g

Is there any way to get an indexer for $2. For example $2.4 or $2(4)
would get me the fourth letter.


Look at the documentation for Group.Captures: I think it does exactly what
you want.

Niki
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
8331
by: Nikhil Patel | last post by:
Hi all, Is it possible to have more than one indexer in a class. If not, are there any good alternative ways to achieve similar functionality. Thanks... -Nikhil
4
1685
by: Dotnetjunky | last post by:
Hi, I'm really get confused on this issue. Hope that someone can help me get clear after this post. Take the class System.Web.Caching.Cache for example. In the documentation, there's a...
3
2523
by: george r smith | last post by:
I am converting a delphi chess program to C#, this is how I study a new language and I have the following problem. How do you use an enumeration value as an indexer for an array ? This is what I...
2
1399
by: Jerry Negrelli | last post by:
I'm trying to define a custom class indexer to take the place of an underlying Hashtable member so that values can be referred to as Class1 instead of Class1.someVar. The following code does...
7
4607
by: Steph | last post by:
I'm learning C#. I need to implement an indexer using an array list. I have the following code and I'm getting an error "Inconsistent accessibility: indexer return type CRegs is less accessible...
5
1847
by: SpotNet | last post by:
Hello NewsGroup, I have a custom class and a collection for that custom class that inherits CollectionBase. As such; public class MyClass { private string datamember1 = string.Empty,...
17
3940
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 ...
17
2051
by: SemSem | last post by:
i want to know waht is an index and how we use it with a simple example including the main of the program . thanx -- Islam Khalil,
2
1962
by: hufaunder | last post by:
SITUATION: I have a class "MainClass" that has an indexer "SubClass1Indexer". This indexer returns an instance that implements a particular interface "ISubClass1". This interface defines another...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.