什么是匹配特定字符串上方文本中所有内容的正则表达式?
字符串为=============REPLY ABOVE THIS LINE=============
,我希望使用 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
答案 0 :(得分:1)
为什么不这样做呢?
$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]);