Here is a line in Java.
String string="abc$[A]$def$[B]$ghi";
I want to find the words that are in the pattern $[*]$ . The result above the line: A , B
$[*]$
A
B
String s = "abc$[A]$def$[B]$ghi"; Pattern p = Pattern.compile("\\$\\[.*?\\]\\$"); Matcher m = p.matcher(s); while(m.find()){ String b = m.group(); System.out.println(">> " +b.substring(2, b.length()-2)); }
Use regex. In Java, you can use a template class .
You can use regular expressions for this. Take a look at the Pattern and Matcher classes.
The regular expression that you would use in this case would be:
\$\[.*?\]\$
Alternatively, you can work with String.indexOf and String.substr .
Source: https://habr.com/ru/post/1436762/More articles:to create a secure password in javascript - javascriptjquery or javascript password generator with at least capital and number - javascriptPHP / MySQL: joining three tables and joining results - sqlcalling an action in the controller via jQuery from cshtml and returning the value back - jqueryChange wise time checking in sql server - sql-serverJQuery password generator - javascriptTeamCity: parameter in the artifact settings, cannot be changed from the service message - parametersCURL receives a file only if it has been modified - phpmoving an object in a list, deleting and returning it - listHow can I call a method on an instance using MSIL * without * having MethodInfo? - reflectionAll Articles