/* 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
{
{
// your code goes here
CharSequence chSeq = "AND ((:aks_num = -1) OR (aks_num = :aks_num AND ((:brn_num = -1) OR (brn_num = :brn_num))))";
// replaceAll also not working
//String s = chSeq.replaceAll(":\\([a-z_]*\\)","\\${ $1 \\}$");
Pattern p = Pattern.compile(":(\\w+)");
Matcher m = p.matcher(chSeq);
while (m.find()) {
System.
out.
println("Found value: " + m.
group(1) ); }
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguTWF0Y2hlcjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJCUNoYXJTZXF1ZW5jZSBjaFNlcSA9ICJBTkQgKCg6YWtzX251bSA9IC0xKSBPUiAoYWtzX251bSA9IDpha3NfbnVtIEFORCAoKDpicm5fbnVtID0gLTEpIE9SIChicm5fbnVtID0gOmJybl9udW0pKSkpIjsKCiAgICAvLyByZXBsYWNlQWxsIGFsc28gbm90IHdvcmtpbmcKICAgIC8vU3RyaW5nIHMgPSBjaFNlcS5yZXBsYWNlQWxsKCI6XFwoW2Etel9dKlxcKSIsIlxcJHsgJDEgXFx9JCIpOwoKICAgIFBhdHRlcm4gcCA9IFBhdHRlcm4uY29tcGlsZSgiOihcXHcrKSIpOwogICAgTWF0Y2hlciBtID0gcC5tYXRjaGVyKGNoU2VxKTsKCiAgICB3aGlsZSAobS5maW5kKCkpIHsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJGb3VuZCB2YWx1ZTogIiArIG0uZ3JvdXAoMSkgKTsKICAgICAgfQoJfQp9