/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String INDEX_REGEX
= "\\[index='(\\d+)'\\]"; // your code goes here
String input
= "/interfaces/interface[name='ge-0/0/2']/subinterfaces/subinterface[index='110']/ipv4/addresses/address[ip='10.1.1.2']"; Pattern pattern = Pattern.compile(INDEX_REGEX);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
indexVal = matcher.group(1);
}
System.
out.
print("Mounica ::: " + indexVal
);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguTWF0Y2hlcjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTdHJpbmcgSU5ERVhfUkVHRVggPSAiXFxbaW5kZXg9JyhcXGQrKSdcXF0iOwoJCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCQlTdHJpbmcgaW5wdXQgPSAiL2ludGVyZmFjZXMvaW50ZXJmYWNlW25hbWU9J2dlLTAvMC8yJ10vc3ViaW50ZXJmYWNlcy9zdWJpbnRlcmZhY2VbaW5kZXg9JzExMCddL2lwdjQvYWRkcmVzc2VzL2FkZHJlc3NbaXA9JzEwLjEuMS4yJ10iOwogICAgICAgIFN0cmluZyBpbmRleFZhbCA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