关于PHP正则表达式的问题

Nan*_* HE 1 php regex

我是PHP正则表达式的新手,我读了http://php.net/manual/en/function.preg-match.php.但找不到修复我的bug的方法.你能帮我个忙吗?谢谢.

<?php

$myURL = "/something/";  
// If myURL include two or more than two '/' then return Found, Else return Not found two '/'

if (preg_match("/\/?\//", $myURL)) {
    echo "found";
} else {
    echo "not found";
}
?>
Run Code Online (Sandbox Code Playgroud)

Sha*_*ali 6

我建议使用substr_count.

$numSlashes = substr_count($text, '/');
Run Code Online (Sandbox Code Playgroud)

夏嘉曦.