Hi Tom Jones,
I assume you want to get every "a." Try to do this:
A short example.
Codes:
using System;
using System.Text.RegularExpressions;
class RegEx
{
public static void Main()
{
MatchCollection mCollect;
String[] results = new String[20];
int[] mPosition = new int[20];
Regex r = new Regex("a.");
mCollect = r.Matches("a.c.a.a.a.a.a.a.f.g.g.ggg.c.a.");
for (int i = 0; i < mCollect.Count; i++)
{
results[i] = mCollect[i].Value;
Console.WriteLine(results[i]);
mPosition[i] = mCollect[i].Index;
Console.WriteLine(mPosition[i]);
}
}
}
Hope it helps. Correct me if i am wrong.
--
Regards,
Chua Wen Ching :)
"Tom Jones" wrote:
Hi,
I cannot seem to figure out how to construct a regex for what I need.
I need to match:
a
or
a.a.a.a // note: there can be any number of ".a" repetitions
or
a.*
or
a.a.a.a.*
where 'a' can be "one or more contiguous alpha chars".
The optional repetition is throwing me...
Any pointers are appreciated...
Thanks,
Tom