Oops, some errta correction.
Pattern p=new Pattern.compile("dialer%instance%.+%name");
Matcher matcher=p.matcher("dialer%instance%name");
System.out.print(matcher.matches()) ==> This prints 'true'!
How come, it matches? I expected e.g) "dialer%instance%1%name"
or "dialer%instance%2%name" would only match. But, why
"dialer%instance%name" also matches the pattern specified?
Rather than posting errata, it seems to be time for a Short,
Self-Contained, Compilable Example (SSCCE). I tried to construct one
from the snippet you posted. I had edit out "new " to get it to compile,
so I know what you posted is not what you are running. This program
prints "false", so some difference from what you are running is
significant.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PatternTest {
public static void main(String[] args) {
Pattern p=Pattern.compile("dialer%instance%.+%name");
Matcher matcher=p.matcher("dialer%instance%name");
System.out.print(matcher.matches());
}
}
Your best bet for getting help is to edit this example to make it match
what you are doing, and post the new version. Make sure you copy-paste,
with no retyping, when you post it, so that the program in the message
is EXACTLY the program you are running.
Keep the form of a very short but complete program. Anyone who wants to
help you should be able to copy-paste the program from your message into
their favorite Java editor and reproduce your problem without having to
add, delete, or change a single byte.
Patricia