如何编写 preg_match 来匹配字符串*My*
?
这不起作用:
$ptn = "/\*(.*)\*/";
$str = "*My*";
preg_match($ptn, $str, $matches);
print_r($matches);
因为它输出:
Array
(
[0] => *My*
[1] => *My*
)
代替:
Array
(
[0] => *My*
[1] => My
)
如何编写 preg_match 来匹配字符串*My*
?
这不起作用:
$ptn = "/\*(.*)\*/";
$str = "*My*";
preg_match($ptn, $str, $matches);
print_r($matches);
因为它输出:
Array
(
[0] => *My*
[1] => *My*
)
代替:
Array
(
[0] => *My*
[1] => My
)