php:如何用正则判断一个字符串是否以"_ui"结尾呢?

如何符合echo "success",如果不符合则echo "error"该如何实现呢?求解

<?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));
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-03
正则判断一下就好了
相似回答