/* package whatever; // don't place package name! */

import java.util.*;
import java.util.regex.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Pattern p;
		try {
			p = Pattern.compile("\\[(?<text>[^\\]]*)\\]\\((?<link>[^\\)]*)\\)");
		} catch (PatternSyntaxException ex) {
			System.out.println(ex);
			throw(ex);
		}
		Matcher m1 = p.matcher("Hello");
		Matcher m2 = p.matcher("Hello [world](ladies)");
		Matcher m3 = p.matcher("Well, [this](that) has [two](too many) keys.");
		System.out.println("m1 matches: " + m1.matches());
		System.out.println("m2 matches: " + m2.matches());
		System.out.println("m3 matches: " + m3.matches());
		m2.start();
		m3.start();
		System.out.println("m2 text: " + m2.group("text"));
		System.out.println("m2 link: " + m2.group("link"));
		System.out.println("m3 text: " + m3.group("text"));
		System.out.println("m3 link: " + m3.group("link"));
		System.out.println("m3 count: " + m3.groupCount());
		System.out.println("m3 find: " + m3.find());
	}
}