import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\| right \\= (.*)\\n\\| name \\= (.*)\\n\\| bottom \\= (.*)\\n\\| top \\= (.*)\\n\\| image \\= (.*)\\n\\| left \\= (.*)\\n";
final String string = "{{#switch:{{{1}}}\n"
+ "| right = 172.667\n"
+ "| name = Yeni Zelanda Christchurch cadde\n"
+ "| bottom = -43.547\n"
+ "| top = -43.52\n"
+ "| image = Location map New Zealand Christchurch.png\n"
+ "| left = 172.613\n"
+ "}}<noinclude>[[Kategori:Yeni Zelanda konum haritası şablonları]]{{Konum haritası/Bilgi}}</noinclude>";
final String subst = "right = \\1,\\nname = \\2,\\nbottom = \\3,\\ntop = \\4,\\nimage = \\5,\\nleft = \\6\\n}";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html