import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(^[a-zA-z0-9]{32})";
final String string = "2629f4a363e64a36bbd86c01dfac5168\n"
+ "ff29ac3148394d1bbbcf85a7d0fd27dd\n"
+ "c627930216bc439db8563451be4d8172\n"
+ "4ed84dd2bb68430e9c4d43884088b364\n"
+ "84ab4c45d2194651bfa6729ad81cdcb9\n"
+ "6fb2f2de90ab45f4976a699099d30697\n"
+ "2d80f4090d0244b4b92ce505874a5f95\n"
+ "f231e374e45a4f2da1b1dc2c6bcb5991\n"
+ "91d13e50695140a7b4d66a28880986ef\n"
+ "3ef3a3990b5e4870840068b500359fca\n"
+ "43fc4ca5d3a544a49aa0fb6d6e28ceb5\n"
+ "48e54b84562a41f98224773a163c3123\n"
+ "be7f7602169844138ef2a9ab66ac38b6\n"
+ "d2f3b5f91512431b86d943c89fa9b8c4\n"
+ "18ecb09cf4b94e4d91ec1b3efa97ea1f\n"
+ "f7ed1df9200543baac16b1e094278f52\n"
+ "f5b54666ccd84b3b905a5092aaf35a48\n"
+ "c6a224f88afe4ebc8943cab7aedd5d21\n"
+ "da180ef24522404598d69e8eb4f071c5\n"
+ "66ae5365d8294605a9cbb6124773d8c4\n"
+ "ba491533d84540e384b4e47280cbdded\n"
+ "d38e9d637dca4d6194ff860187ae9059\n"
+ "9113322aa1404a66ba28732ae59e603b\n\n";
final String subst = "<img src=\"https://vg05.met.vgwort.de/na/$1\" width=\"1\" height=\"1\" alt=\"\">";
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL | 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