Thanks for helping, Kevin,
but from your example, doesn't that actually yield *two* groups?
(prefix) - and - ([^,])+
~~~~~~~~ ~~~~~~~
This is what I get if I use roles[0].Groups[0].ToString():
abcde
And this I get if I use roles[0].Groups[1].ToString():
e
It always only yields the last character in the capture.
(given my original pattern: Regex.Matches("prefixabcde," ,
@"prefix([^,])+," )
I can't possibly find my error here....
Quite baffled,
Axel
--------------------
Kevin Spencer said:
Hi Axel,
First, Group 0 in .Net is always the entire match. Second, you would
need
to
create a Group to do this. Example:
,@"(prefix)([^,])+,"
Then you would use Groups[1].
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
To a tea you esteem
a hurting back as a wallet.
Nope, doesn't work.. I still get the whole pattern string instead of only
what's within the parentheses..
Any other suggestions, please? (I'm using .NET 1.1)
TIA,
Axel Dahmen
-------------
retValue=roles[0].Groups[0].ToString();
:
Hi,
If I write
roles=Regex.Matches(myRoles,@"prefix([^,])+,");
then
retValue=roles[0].Groups[0].Captures[0].ToString();
returns e.g. "prefix_some_value,".
How can I retrieve just what's within the parentheses, e.g.
"_some_value"?
TIA,
Axel Dahmen