match() static public méthode

preg_match sucks! This tries to make it more convenient
static public match ( string $string, string $preg, string $get = false, string $placeholder = false ) : mixed
$string string
$preg string Regular expression
$get string Which part should be returned from the result array
$placeholder string Default value if nothing will be found
Résultat mixed
Exemple #1
0
 static function parseName($name)
 {
     if (str::contains($name, '-')) {
         $match = str::match($name, '!^([0-9]+[\\-]+)!', 0);
         $uid = str_replace($match, '', $name);
         $num = trim(rtrim($match, '-'));
     } else {
         $num = false;
         $uid = $name;
     }
     return array('uid' => $uid, 'num' => $num);
 }
Exemple #2
0
 static function parseName($name)
 {
     $match = str::match($name, '!^([0-9]+[\\-]+)!', 0);
     $uid = str_replace($match, '', $name);
     $num = trim(rtrim($match, '-'));
     return array('uid' => $uid, 'num' => $num);
 }
Exemple #3
0
function js($url, $async = false)
{
    $url = str::match($url, '~(^\\/\\/|^https?:\\/\\/)~') ? $url : url(ltrim($url, '/'));
    $async = $async ? ' async' : '';
    return '<script' . $async . ' src="' . $url . '"></script>' . "\n";
}