Pull request #472: RSS-105: Use string after match of first regEx for second regex in redactBetweenRegexes

Merge in RED/redaction-service from RSS-105 to master

* commit '5503dbfffc10ef9f51da7c37cb66e933d747a874':
  RSS-105: Use string after match of first regEx for second regex in redactBetweenRegexes
This commit is contained in:
Dominique Eiflaender 2022-09-15 13:08:42 +02:00 committed by Philipp Schramm
commit d2f2cd975c

View File

@ -605,8 +605,15 @@ public class Section {
@Argument(ArgumentType.BOOLEAN) boolean skipRemoveEntitiesContainedInLarger,
@Argument(ArgumentType.BOOLEAN) boolean sortedResult) {
String startValue = getFirstRexExMatch(startPattern, startPatternCaseInsensitive, startGroup);
String stopValue = getFirstRexExMatch(stopPattern, stopPatternCaseInsensitive, stopGroup);
String startValue = getFirstRexExMatch(searchText, startPattern, startPatternCaseInsensitive, startGroup);
if (startValue == null){
return;
}
String searchTextAfter = StringUtils.substringAfter(searchText, startValue);
String stopValue = getFirstRexExMatch(searchTextAfter, stopPattern, stopPatternCaseInsensitive, stopGroup);
if (startValue != null && stopValue != null) {
redactBetween(startValue, stopValue, includeStart, includeStop, type, ruleNumber, false, false, reason, legalBasis, true, skipRemoveEntitiesContainedInLarger, sortedResult);
@ -1148,10 +1155,10 @@ public class Section {
}
private String getFirstRexExMatch(String pattern, boolean patternCaseInsensitive, int group) {
private String getFirstRexExMatch(String text, String pattern, boolean patternCaseInsensitive, int group) {
Pattern compiledPattern = Patterns.getCompiledPattern(pattern, patternCaseInsensitive);
Matcher matcher = compiledPattern.matcher(searchText);
Matcher matcher = compiledPattern.matcher(text);
while (matcher.find()) {
String match = matcher.group(group);