import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?i)(?<=Empfänger)([\\s]*)\\b([\\S\\t ]*)\\b";
final String string = "Ladeliste: speditions\n"
+ "logistics\n"
+ "GmbH\n"
+ "-\n"
+ "D-9999 Speditionsstadt\n"
+ "Seite 1\n"
+ "Kunde:\n"
+ "Chrsitkind SE (#41155~42784)\n"
+ "16.10.2019 11:20\n"
+ "Sendungs-Nr: 0002011147\n"
+ "Auftrags-Nr: 11161\n"
+ "Frankatur: frei Haus\n"
+ "Depot: 007\n"
+ "Auftraggeber Christkind-\n"
+ "*\n"
+ "(#41155~42784)\n"
+ "9999 Wunderstandt\n"
+ "*\n"
+ "Wunderstraße 001\n"
+ "Empfänger Max Muster TEST\n"
+ "99992 Musterstadt\n"
+ "*\n"
+ "Musterstraße\n"
+ "1\n"
+ "Lieferavis\n"
+ "mustermannmax@gmx.de\n"
+ "Ladezeit\n"
+ "17.10.19\n"
+ "Termin\n"
+ "B2CLine\n"
+ "Hinweis-Schl: nur mit Hebebühne zustellen\n"
+ "Avis Festnetz: 0177007007007 / 000 32586914\n"
+ "S-Zeilen:\n"
+ "1 EE\n"
+ "Saunaaufguss\n"
+ "315\n"
+ "kg 120x080x120 1,152cbm\n"
+ "Calnids\n"
+ "100 340294943036198282\n"
+ "DRAN 000 TTAN\n"
+ "**\n"
+ "1\n"
+ "Sdg., 1 Colli (1 EE), gesamt 315 kg.";
final String subst = "";
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