我試圖在每個包含句號的文件上運行preg_match。Preg match full stop
<?php
$furl = "Maid with the Flaxen Hair.mp3";
if (preg_match("/./i", $furl)) {
echo "Contains full stop";
}
?>
有人可以幫忙嗎?
我試圖在每個包含句號的文件上運行preg_match。Preg match full stop
<?php
$furl = "Maid with the Flaxen Hair.mp3";
if (preg_match("/./i", $furl)) {
echo "Contains full stop";
}
?>
有人可以幫忙嗎?
替代,也快然後的preg_match
if (strpos($furl, '.') !== false)
{
echo "Contains full stop";
}
.
正則表達式中的意思是 「匹配什麼」。以此逃脫\.
。 (儘管在這種情況下strpos可能更快)
<?php
$furl = "Maid with the Flaxen Hair.mp3";
if (preg_match("/\./", $furl)) {
echo "Contains full stop";
}
?>
在正則表達式中,'。'匹配任何字符。如果您想將其限制爲真實的'。',請使用'\'將其轉義。
你也不需要/我,因爲沒有涉及的字母。