0

我想在大文本内容中搜索关键字并输出这一行。我的示例文本如下:

所提出的基于 RTD 的纳米架构的嵌套列表的 HSPICE 模拟方法,以通过使用上述表示方法来验证图像函数的候选者。

类别和主题描述符:C.5.4 [计算机系统实现]:VSLI Systems

通用术语:设计附加关键词和短语:VLSI、量化、颜色提取、彩色图像处理、共振-

隧道二极管,细胞神经网络

ACM 参考格式:

最后我想通过搜索关键词“通用术语”来输出“通用术语:设计附加关键词和短语:VLSI、量化、颜色提取、彩色图像处理、共振-”。我怎样才能在 PHP 中编码得到这个结果?对于整个文本,让它成为 $content,并且 $key="General Terms";

4

1 回答 1

0

您想使用正则表达式 - http://www.php.net/manual/en/function.preg-match.php

$search = 'General Terms:';

$pattern = '/'.$search.'(.)+/';

$content = 'HSPICE simulation methods for the nestlist of the proposed RTD-based nanoarchitecture in order to verify a candidate of image functions by using the afore-mentioned representation methods.

Categories and Subject Descriptors: C.5.4 [Computer System Implementation]: VSLI Systems

General Terms: Design Additional Key Words and Phrases: VLSI, quantization, color extraction, color image processing, resonant-

tunneling diode(s), cellular neural network';

preg_match($pattern, $content, $out);
$out[0] = str_replace($search, '', $out[0]);
print_r($out);
// Array ( [0] => Design Additional Key Words and Phrases: VLSI, quantization, color extraction, color image processing, resonant- [1] => )
于 2013-10-15T23:55:37.987 回答