public static function extract($str)
    {
        preg_match_all("/(^|[\n ])#([a-z0-9_-]*)/is", $str, $matches);

        if (!is_array($matches) || !count($matches)) {
            return [];
        }

        $hashtags = [];
        foreach ($matches[0] as $match) {
            $match = ltrim(trim($match), '#_ ');
            if (self::isValid($match)) {
                $hashtags[strtolower($match)] = $match;
            }
        }

        return array_values($hashtags);
    }
public static function extract($str)
    {
        preg_match_all("/(^|[\n ])#([a-z0-9_-]*)/is", $str, $matches);

        if (!is_array($matches) || !count($matches)) {
            return [];
        }

        $hashtags = [];
        foreach ($matches[0] as $match) {
            $match = ltrim(trim($match), '#_ ');
            if (self::isValid($match)) {
                $hashtags[strtolower($match)] = $match;
            }
        }

        return array_values($hashtags);
    }
public static function extract ( $ str ) { preg_match_all ( "/(^|[\n ])#([a-z0-9_-]*)/is" , $ str , $ matches ) ; if ( ! is_array ( $ matches ) || ! count ( $ matches ) ) { return [ ] ; } $ hashtags = [ ] ; foreach ( $ matches [ 0 ] as $ match ) { $ match = ltrim ( trim ( $ match ) , '#_ ' ) ; if ( self :: isValid ( $ match ) ) { $ hashtags [ strtolower ( $ match ) ] = $ match ; } } return array_values ( $ hashtags ) ; }
Extracts all of the valid hashtags from a string.  multi-line strings
will work with this method.

@param string $str

@return array
Extracts all of the valid hashtags from a string . multi - line strings will work with this method .