match class : Index getter

Description

Gets a position of the substring in the original string.

Syntax

matchInstance.Index

Arguments

None

Return value

ClassDescription
intA position of the substring in the original string.

Sample code

1:

regex pattern = new regex("(b+)");

2:

match firstMatch= pattern.MatchM("aaabbbaaccc"); // "bbb"

3:

int index = firstMatch.Index; // 3

Notes

It's a wrapper of the System.Text.RegularExpressions.Match.Index property.

The position is indicated by a zero-based index.

Links for reference

Copyright © Cooker All rights reserved.