src/Anshar/Utils/StringHelper.php
public function affectChunks(callable $function, ...$delimiters)
    {
        $delimiter_string = "";
        $replace_callback = function ($matches) use ($function) {

            $callback_string = $function($matches[0]);

            return $callback_string;
        };

        foreach ($delimiters as $delimiter) {
            $delimiter_string .= preg_quote($delimiter, "/");
        }

        $pattern = "/[^{$delimiter_string}]+/";

        $affected_string = preg_replace_callback($pattern, $replace_callback, $this->string);

        return $affected_string;
    }
public function affectChunks(callable $function, ...$delimiters)
    {
        $delimiter_string = "";
        $replace_callback = function ($matches) use ($function) {

            $callback_string = $function($matches[0]);

            return $callback_string;
        };

        foreach ($delimiters as $delimiter) {
            $delimiter_string .= preg_quote($delimiter, "/");
        }

        $pattern = "/[^{$delimiter_string}]+/";

        $affected_string = preg_replace_callback($pattern, $replace_callback, $this->string);

        return $affected_string;
    }
public function affectChunks ( callable $ function , ... $ delimiters ) { $ delimiter_string = "" ; $ replace_callback = function ( $ matches ) use ( $ function ) { $ callback_string = $ function ( $ matches [ 0 ] ) ; return $ callback_string ; } ; foreach ( $ delimiters as $ delimiter ) { $ delimiter_string .= preg_quote ( $ delimiter , "/" ) ; } $ pattern = "/[^{$delimiter_string}]+/" ; $ affected_string = preg_replace_callback ( $ pattern , $ replace_callback , $ this -> string ) ; return $ affected_string ; }
Given a delimited string, returns a copy of the string with chunks defined by the delimiter affected by a given
function.

The supplied function must be callable and must accept a string as its only required parameter

@param callable $function    The function to be called against the delimited chunks; must be callable and must
accept a string as its only parameter
@param string[] $delimiters  One or more strings delimiting the chunks

@return string               A delimited string with chunks affected by the supplied function
Given a delimited string returns a copy of the string with chunks defined by the delimiter affected by a given function .