Here is a string like this in Java.
String string="abc$[A]$def$[B]$ghi";
I want to search words that are located in $[*]$ pattern. The result of above the string is A, B.
You could use regular expressions for that. Take a look at the classes Pattern and Matcher.
The regular expression you would use in that case would be:
\$\[.*?\]\$
Alternatively, you could work with String.indexOf and String.substr.