如何删除总是以"author-"开头但连字符后面的完整字符串在每页上可能有所不同。
您可以使用以下preg_replace
表达式
preg_replace("/^author-.*$/", "", $field);
if( false !== strpos( $string, 'author-' ) )
{
unset( $string );
}
或
$string = preg_replace( '/author-.*/', '', $string );
(未测试)
是的,你可以使用pcre。
$string = "
title-one
author-two
date-three
who-author-
";
echo preg_replace('/^author'-.*$/m', '', $string);
我使用m修饰符来分别处理每一行