douya1061 2013-11-29 08:46
浏览 13
已采纳

得到第一个以。结尾的句子。 ! ? 换行之间[关闭]

Please tell me how to get the first sentence between line breaks and ending signs. ! ? For example i have some text:

"1)Airbus Industrie began as a consortium of European aviation firms to compete with American companies such as Boeing, McDonnell Douglas, and Lockheed. While many European aircraft were innovative, even the most successful had small production runs.

2)In 1991, Jean Pierson, then CEO and Managing Director of Airbus Industrie, described a number of factors which explained the dominant position of American aircraft manufacturers.

3)The land mass of the United States made air transport the favoured mode of travel; a 1942 Anglo-American agreement entrusted transport aircraft production to the US; and World War II had left America with a profitable, vigorous, powerful and structured aeronautical industry.

4)The retention of production and engineering assets by the partner companies in effect made Airbus Industrie a sales and marketing company. This arrangement led to inefficiencies due to the inherent conflicts of interest that the four partner companies faced.

5)BAE Systems and EADS transferred their production assets to the new company, Airbus SAS, in return for shareholdings in that company. "

You can see in the second and four paragraphs we have top and bottom line break, and the text is a sentence. But in four paragraphs we have two sentence. I need parse text where only one sentence in paragraph(for example this is second paragraphs), and when they ending signs. ! ?

I get text between line break:

preg_match_all("/^[
](.*)[
]/m", $text, $content);

I know it may be simple change in (.*), for example (.*|\.|\?|\!), but it not work.

  • 写回答

1条回答 默认 最新

  • dongpan5289 2013-11-29 09:01
    关注

    /^([^.?!]*)/m

    It captures the entire first sentence, leaving out any ending punctuation and line breaks.

    Try this. You can see a working example here: http://regex101.com/r/aK4aL3

    You can see it matching the first sentence where applicable, and leaving out the rest.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料