dnet-hadoop/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/FundRefCleaningRule.java

26 lines
441 B
Java
Raw Normal View History

2023-06-09 16:47:25 +02:00
package eu.dnetlib.dhp.schema.oaf.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FundRefCleaningRule {
public static final Pattern PATTERN = Pattern.compile("\\d+");
2023-06-09 16:47:25 +02:00
public static String clean(final String fundRefId) {
String s = fundRefId
2023-06-09 16:47:25 +02:00
.toLowerCase()
.replaceAll("\\s", "");
Matcher m = PATTERN.matcher(s);
if (m.find()) {
2023-06-09 16:47:25 +02:00
return m.group();
} else {
return "";
}
}
}