【发布时间】:2017-10-08 17:04:57
【问题描述】:
这是我的原始字符串:-
$data = "<br />
Q.156) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
<br />
Q.157) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
<br />
Q.158) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
<br />
Q.159) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
<br />
Q.160) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
<br />
Q.161) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
<br />
Q.162) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow: <br />
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department <br />
";
我想以这种格式将我的字符串拆分为数组
Array (
[0] => Q.156) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
[1] => Q.157) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
[2] => Q.158) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
[3] => Q.159) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
[4] => Q.160) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
[5] => Q.161) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
[6] => Q.162) Direction (156–160): Study the given pie-charts carefully to answer the questions that follow:
Breaking up :- Number of Employees working in Different Departments of an Organisation, the Number of Males and the Number of Employees Who Recently Got Promoted in Each Department
)
我知道我可以使用preg_split('/[Q[.]]+/', $data)
但我在 regex 方面有点弱。 请帮助我的正则表达式合并相应..
【问题讨论】:
-
不,我必须保留中断标签。
-
@chris85 干得好....但是我需要像
Q.1234)这样的通用内容,因为您看到 . ("/d") .. 现在最终的正则表达式是什么
标签: php regex preg-match-all preg-split