Skip to content

Commit

Permalink
Updated Regex for piped function placeholder
Browse files Browse the repository at this point in the history
Signed-off-by: David Joos <david.joos@bosch-si.com>
  • Loading branch information
David Joos authored and ffendt committed Feb 26, 2019
1 parent 4744840 commit f341b20
Showing 1 changed file with 14 additions and 4 deletions.
Expand Up @@ -18,6 +18,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand All @@ -33,7 +34,8 @@
@Immutable
final class ImmutableExpressionResolver implements ExpressionResolver {

private static final String PIPE_PATTERN_STR = "(\\s+\\|\\s+)";
private static final String PIPE_PATTERN_STR = "\\s*[\\w\\:\\-]+(\\((((\\'|\\\")[^\\'^\\\"]+(\\'|\\\"))|" +
"([\\w\\:\\-]+)|\\s*)\\))*\\s*";
private static final Pattern PIPE_PATTERN = Pattern.compile(PIPE_PATTERN_STR);

private static final Function<String, DittoRuntimeException> UNRESOLVED_INPUT_HANDLER = unresolvedInput ->
Expand Down Expand Up @@ -84,9 +86,17 @@ private Function<String, Optional<String>> makePlaceholderReplacerFunction(

return template -> {

final List<String> pipelineStagesExpressions = PIPE_PATTERN.splitAsStream(template)
.map(String::trim)
.collect(Collectors.toList());
Matcher matcher = PIPE_PATTERN.matcher(template);

final List<String> pipelineStagesExpressions = new ArrayList<>();

while(matcher.find()) {
pipelineStagesExpressions.add(matcher.group().trim());
}

// final List<String> pipelineStagesExpressions = PIPE_PATTERN.splitAsStream(template)
// .map(String::trim)
// .collect(Collectors.toList());

final String placeholderTemplate =
pipelineStagesExpressions.get(0); // the first pipeline stage has to start with a placeholder
Expand Down

0 comments on commit f341b20

Please sign in to comment.