Php 什么是将匹配特定字符串上方所有内容的正则表达式?
什么是正则表达式,它将匹配特定字符串上方文本中的所有内容 字符串是Php 什么是将匹配特定字符串上方所有内容的正则表达式?,php,regex,Php,Regex,什么是正则表达式,它将匹配特定字符串上方文本中的所有内容 字符串是=====================================,我想使用PHP获取上面的所有内容 示例文本 this is a sample text here i want to match using regex. because it is above the following line =============REPLY ABOVE THIS LINE============= here is below
=====================================
,我想使用PHP获取上面的所有内容
示例文本
this is a sample text here i want to match using regex. because it is above the following line
=============REPLY ABOVE THIS LINE=============
here is below the line
因此正则表达式将仅返回
this is a sample text here i want to match using regex. because it is above the following line
为什么不这样做呢
$input = "this is a sample text here i want to match using regex. because it is above the following line =============REPLY ABOVE THIS LINE============= here is below the line"
$pieces = explode("=============REPLY ABOVE THIS LINE=============", $input);
$above_line = trim($pieces[0]);
$below_line = trim($pieces[1]);
@戴尔:是的,同意,很抱歉。当我得到回复时,我会将我的答案编辑成实际答案。@villoui调整了我的答案:)