我想检查是否字符串包含任何形式的以下模式如何找到,如果字符串包含的子字符串格式(spaceNUMBER-NUMBERspace)
(空间 NUMBER-NUMBER 空间)的实例(1 -0)
类似:
$str1 = '21-02-2017 - child 1-9 my parent';
$str2 = '21-02-2017 - child - my parent';
$bool_val= True;
if(checkContain($str1))
{
$bool_val = True; //True because contains (1-9)
}
if(checkContain($str2))
{
$bool_val = False;
}
function checkContain($str){
// ??
}
谢谢!
您可能想检查在[官方PHP网站](http://php.net/manual/en/pcre.pattern.php)中找到的文档。当然,所有[PCRE函数](http://php.net/manual/fr/ref.pcre.php)都可以使用PCRE规范。 –