php正则检测字符串由单一字符组成

$str = 'aaa'
$firstChar = substr($str , 0, 1);
$pattern = "/^[$firstChar]+$/";
$ret = preg_match($pattern, $str );

猜你喜欢

转载自www.cnblogs.com/xiaoyucoding/p/9486604.html