Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
This is one of my regular expressions:
(?<RollP>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?),(?<RollI>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)


The input would be 2 floats separated by a comma
2.34,-23


It creates 2 main groups "RollP" and "RollI" and i want to be able to take the GroupCollection values and put it into a dictionary like so
"RollP":"2.34"
"RollI":"-23"


But using reg.GroupNameFromNumber has me stumped. There are unnamed groups within the overall group expressions to check the floats.

How could i recurse the list or change the expression to get me to the top name which would be either RollP or RollI and still give me the associated string value?
Posted
Updated 26-Jul-10 4:11am
v4

1 solution

Try indexing the Groups by Name:
myMatch.Groups["RollP"]

and so on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900