StackFormation\Preprocessor::split PHP Method

split() protected method

protected split ( $jsonString )
    protected function split($jsonString)
    {
        return preg_replace_callback('/(\\s*)(.*){\\s*"Fn::Split"\\s*:\\s*\\[\\s*"(.*?)"\\s*,\\s*"(.*?)"\\s*\\]\\s*}/', function (array $matches) {
            if (empty($matches[3])) {
                throw new \Exception('Delimiter cannot be empty');
            }
            if (empty($matches[4])) {
                throw new \Exception('String cannot be empty');
            }
            $pieces = explode($matches[3], $matches[4]);
            return $matches[1] . $matches[2] . '["' . implode('", "', $pieces) . '"]';
        }, $jsonString);
    }