sgm4231
$str="你好<我>(爱)[北京]{天安门}";
echo f1($str); //返回你好 
echo f2($str); //返回我 
echo f3($str); //返回爱 
echo f4($str); //返回北京 
echo f5($str); //返回天安门
function f1($str) 
{ 
$result = array(); 
preg_match_all("/^(.*)(?:<)/i",$str, $result); 
return $result[1][0]; 
} 
 
function f2($str) 
{ 
$result = array(); 
preg_match_all("/(?:<)(.*)(?:>)/i",$str, $result); 
return $result[1][0]; 
}
function f3($str) 
{ 
$result = array(); 
preg_match_all("/(?:\()(.*)(?:\))/i",$str, $result); 
return $result[1][0]; 
}
function f4($str) 
{ 
$result = array(); 
preg_match_all("/(?:\[)(.*)(?:\])/i",$str, $result); 
return $result[1][0]; 
}
function f5($str) 
{ 
$result = array(); 
preg_match_all("/(?:\{)(.*)(?:\})/i",$str, $result); 
return $result[1][0]; 
}

链接:https://www.jianshu.com/p/1926b0e7dc65

分类:

技术点:

相关文章:

  • 2021-11-27
  • 2022-01-07
  • 2021-10-16
  • 2021-12-16
  • 2021-05-08
  • 2021-06-12
  • 2021-05-02
  • 2021-12-23
猜你喜欢
  • 2021-11-17
  • 2021-11-17
  • 2021-10-29
  • 2021-09-17
  • 2021-09-28
  • 2021-08-12
  • 2021-11-30
相关资源
相似解决方案