0

嗨,我有一段:

 output:
       I am Deepak
       I study Computers
       I find it interesting
       I like listening to music
       You also like listening to music

我想从“输出”提取到“我喜欢”:

 output:
       I am Deepak
       I study Computers
       I find it interesting
       I like

这是我使用的正则表达式: (?<=output)([^\n]*)(?=listening to music) 。但我没有得到我所期望的。

这就是我得到的:

 output

       I am Deepak
       I study Computers
       I find it interesting
       I like listening to music
       You also like 

任何人都可以帮忙吗?

4

1 回答 1

0

使用非贪婪量化:

output[^\n]*?(?= listening to music)

(我想你实际上想要“输出”这个词。)

于 2013-08-17T17:54:36.067 回答