public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self
    {
        if ($regEx) {
            \preg_match_all($regEx, $str, $array);

            if (!empty($array)) {
                $array = $array[0];
            }
        } else {
            /** @noinspection NestedPositiveIfStatementsInspection */
            if ($delimiter !== null) {
                $array = \explode($delimiter, $str);
            } else {
                $array = [$str];
            }
        }

        // trim all string in the array
        \array_walk(
            $array,
            static function (&$val) {
                if (\is_string($val)) {
                    $val = \trim($val);
                }
            }
        );

        return static::create($array);
    }
public static function createFromString(string $str, string $delimiter = null, string $regEx = null): self
    {
        if ($regEx) {
            \preg_match_all($regEx, $str, $array);

            if (!empty($array)) {
                $array = $array[0];
            }
        } else {
            /** @noinspection NestedPositiveIfStatementsInspection */
            if ($delimiter !== null) {
                $array = \explode($delimiter, $str);
            } else {
                $array = [$str];
            }
        }

        // trim all string in the array
        \array_walk(
            $array,
            static function (&$val) {
                if (\is_string($val)) {
                    $val = \trim($val);
                }
            }
        );

        return static::create($array);
    }
public static function createFromString ( string $ str , string $ delimiter = null , string $ regEx = null ) : self { if ( $ regEx ) { \ preg_match_all ( $ regEx , $ str , $ array ) ; if ( ! empty ( $ array ) ) { $ array = $ array [ 0 ] ; } } else { /** @noinspection NestedPositiveIfStatementsInspection */ if ( $ delimiter !== null ) { $ array = \ explode ( $ delimiter , $ str ) ; } else { $ array = [ $ str ] ; } } // trim all string in the array \ array_walk ( $ array , static function ( & $ val ) { if ( \ is_string ( $ val ) ) { $ val = \ trim ( $ val ) ; } } ) ; return static :: create ( $ array ) ; }
Create an new Arrayy object via string.

@param string      $str       <p>The input string.</p>
@param string|null $delimiter <p>The boundary string.</p>
@param string|null $regEx     <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be
used.</p>

@return static
<p>(Immutable) Returns an new instance of the Arrayy object.</p>
Create an new Arrayy object via string .