Question: I am currently working on a `WinForms` application using a `Treeview` control. I have added a copy-mechanism to duplicate the currently selected `Treenode`.
The names of the copied `Treenode` objects should be different from the original `Treenode` in the following manner:
"aNode",
"aNode\_1",
"aNode\_2".

It feels like `Regex` is the way to go.

Here is what i've got so far:

```
string theNameToBe = "aName";
List<string> theAlreadyInUseNames   // Filled beforehand
int i = 1;
do
{
    // ToDo: Use Regex to get XXXXX_1 -> XXXXX_2 as a possible name instead of XXXXX_1_1
    Regex aPossibleNewNameRegex = new Regex( String.Format("^{0}[_]\\d+$", theNameToBe),RegexOptions.IgnoreCase);

    // This does not take a previously created XXXXX_1 into account and continues to attach "_1"s to the string
    string thePossibleNewName = String.Format( theNameToBe + "_{0}", i );

    if ( !theAlreadyInUseNames.Any( s => s.Equals( thePossibleNewName, StringComparison.OrdinalIgnoreCase ) ) )
    {
        theNextAvailableName = thePossibleNewName;
        break;
    }

    i++;
} while ( i < int.MaxValue );

```

This only gets subsequent Names like "aNode", "aNode\_1", "aNode\_1\_1", ... and so on.

Can you please help me with my lack of expertise in handlin regular expressions in `C#`?

Edit to clarify:
The next available empty spot should be determined. When later on one of the Nodes/Names is deleted there is a vacant spot. So if only the strings "aName", "aName\_1" and "aName\_3" are present "aName\_2" is the correct finding.

Answer: 
in your build.gradle file, update buildToolsVersion to be 21.1.0 or higher. (You are currently using 20.0.0)

something like:

```
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"
...

```

And also make certain your sdk manager is up to date.

More info : <http://developer.android.com/intl/es/tools/building/multidex.html#mdex-gradle>
Try adding `compile "com.android.support:multidex:1.0.1"` to your dependencies in build.gradle. I believe you need this as well as `multiDexEnabled true`.