private function pattern_to_regex($pattern)
    {
        if (substr($pattern, -1) == '/') {
            $pattern .= '**';
        }

        $regex = '|^';
        foreach (explode('/', $pattern) as $i => $piece) {
            if ($i > 0) {
                $regex .= preg_quote('/', '|');
            }

            if ('**' == $piece) {
                $regex .= '.*';
            } else {
                $regex .= str_replace(array('?', '*'), array('[^/]', '[^/]*'), $piece);
            }
        }
        $regex .= '$|';

        return $regex;
    }
private function pattern_to_regex($pattern)
    {
        if (substr($pattern, -1) == '/') {
            $pattern .= '**';
        }

        $regex = '|^';
        foreach (explode('/', $pattern) as $i => $piece) {
            if ($i > 0) {
                $regex .= preg_quote('/', '|');
            }

            if ('**' == $piece) {
                $regex .= '.*';
            } else {
                $regex .= str_replace(array('?', '*'), array('[^/]', '[^/]*'), $piece);
            }
        }
        $regex .= '$|';

        return $regex;
    }
private function pattern_to_regex ( $ pattern ) { if ( substr ( $ pattern , - 1 ) == '/' ) { $ pattern .= '**' ; } $ regex = '|^' ; foreach ( explode ( '/' , $ pattern ) as $ i => $ piece ) { if ( $ i > 0 ) { $ regex .= preg_quote ( '/' , '|' ) ; } if ( '**' == $ piece ) { $ regex .= '.*' ; } else { $ regex .= str_replace ( array ( '?' , '*' ) , array ( '[^/]' , '[^/]*' ) , $ piece ) ; } } $ regex .= '$|' ; return $ regex ; }
converts ant-pattern to PCRE regex

@param string $pattern
@return string
converts ant - pattern to PCRE regex