we're bit confused why piece of code doesn't throw error we're expecting indexoutofrangeexception
exception.
regex re = new regex(@"(\d+)"); match result = re.match("123456789"); console.writeline(result.groups[1000000000].value);
can explain thoughts his?
groups not array, it's indexed property. it's can return depends on it's code.
public group this[int groupnum] { get; }
upd msdn:
you can determine number of items in collection retrieving value of count property. valid values groupnum parameter range 0 1 less number of items in collection.
the groupcollection object returned match.groups property has @ least 1 member. if regular expression engine cannot find matches in particular input string, single group object in collection has group.success property set false , group.value property set string.empty.
if groupnum not index of member of collection, or if groupnum index of capturing group has not been matched in input string, method returns group object group.success property false , group.value property string.empty.
Comments
Post a Comment