php:如何用正则判断一个字符串是否以"_ui"结尾呢?
2个回答
展开全部
<?php
$str1 = 'dfdfd_ui';
$str2 = 'dfasdfasdf';
function test($str){
preg_match("/.*(\_ui)$/",$str, $matches);
$res = isset($matches[1])&&$matches[1]!=''?'error':'success';
return $res;
}
echo (test($str1));
echo "<br/>";
echo (test($str2));
$str1 = 'dfdfd_ui';
$str2 = 'dfasdfasdf';
function test($str){
preg_match("/.*(\_ui)$/",$str, $matches);
$res = isset($matches[1])&&$matches[1]!=''?'error':'success';
return $res;
}
echo (test($str1));
echo "<br/>";
echo (test($str2));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询