import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?<=:|^)(?!.*:)(?=.*([Ee]ur|EUR)).*";
final String string = "[\n"
+ " \"ERDF : EUR 2.7 million\",\n"
+ " \"ERDF : EUR 961 000\",\n"
+ " \"ERDF: 7 305 000 DKR (+/- EUR 974 000) \",\n"
+ " FEOGA: 40 826 EUR\",\n"
+ " \"49 % of eligible costs\",\n"
+ " \"ERDF contribution: 64%\",\n"
+ " \"FEDER (Objectif 5b 1994-1996) 60 979 euros (400 000 FRF)\",\n"
+ " \"FEDER, Objectif 2, 1994 - 1999: 1 116 000 EUR\",\n"
+ " \"EUR 8.000.000\",\n"
+ " \"EUR 7.200.000\",\n"
+ " \"EUR 4.200.000\",\n"
+ " \"EUR 0.2 million\",\n"
+ " \"EUR 0.6 million\",\n"
+ " \"FEDER: 830 842 euros (5 450 000 FRF)\",\n"
+ " \"EUR 7,220,000,000\",\n"
+ " \"DKR 1 220 000 + DKR 1 380 000 \",\n"
+ " \"GBP 150 000\"\n"
+ "]";
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