如何使用php从此$string
删除 {SEP},日期,名称,冒号(:) ?
$string = "{SEP}09-27-2014 19:38 PM alex : hmm..{SEP}{SEP}09-27-2014 20:04 PM alex : note here..{SEP}{SEP}09-27-2014 20:05 PM alex : testing{SEP}
{SEP}09-27-2014 20:07 PM alex : 1{SEP}{SEP}09-27-2014 20:29 PM alex : abc{SEP}{SEP}09-27-2014 20:30 PM alex : nice..{SEP}{SEP}09-27-2014
20:32 PM alex : checking by pressing the save button.{SEP}{SEP}09-27-2014 20:32 PM alex : Ok now check without save button.{SEP}";
这样看起来像这样:
hmm.. note here..testing 1 abc nice..checking by pressing the save button. Ok now check
without save button.
答案 0 :(得分:1)
preg_replace是一个很好的起点:
echo preg_replace("/\{SEP\}(.+?)\s:\s(.+?)\{SEP\}/m", "$2", $string);