【发布时间】:2010-11-10 22:28:11
【问题描述】:
我遇到了这个 php ucfirst() 来使字符串中每个单词的第一个字符大写。
$foo = 'hello world!';
$foo = ucfirst($foo);
但是如何使用正则表达式和 preg_match() 进行检查,然后显示错误信息?
if (preg_match('/\b\p{Ll}/', $mem_titlename))
{
$error = true;
echo '<error elementid="mem_titlename" message="TITLE - please use uppercase for each word."/>';
}
不确定上面示例中该表达式的含义,但我从与 ucfirst() 执行相同工作的某个地方得到它...
【问题讨论】:
标签: php regex preg-match