/**
 * ****************************************************************************
 * (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0 which accompany this distribution.
 * <p/>
 * The Apache License is available at
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * *****************************************************************************
 */
package io.cloudslang.lang.runtime.bindings;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Bonczidai Levente
 * @since 11/6/2015
 */
public abstract class Binding {

    // match ${ expression } pattern
    private final static String EXPRESSION_REGEX = "^\\s*\\$\\{(.+)\\}\\s*$";
    private final static Pattern EXPRESSION_PATTERN = Pattern.compile(EXPRESSION_REGEX, Pattern.DOTALL);

    protected String extractExpression(Serializable value) {
        String expression = null;
        if (value instanceof String) {
            String valueAsString = ((String) value);

            Matcher expressionMatcher = EXPRESSION_PATTERN.matcher(valueAsString);

            if (expressionMatcher.find()) {
                expression = expressionMatcher.group(1);
            }
        }
        return expression;
    }

}

@@ -1132,17 +1132,16 @@
 value);%0A
-%0A
         
@@ -1215,17 +1215,16 @@
 tring);%0A
-%0A
         

remove newlines