gpt4 book ai didi

ruby - ruby 中的多行正则表达式

转载 作者:数据小太阳 更新时间:2023-10-29 08:17:46 26 4
gpt4 key购买 nike

我正在尝试从我的 Kindle 剪报中删除一些重复的文本,如下所示:

 The starting point,obviously,is a thorough analysis ofthe intellectual property portfolio,the contents ofwhich can be broadly divided into two categories:property that is in use and property that is not in use
==========
Essentials of Licensing Intellectual Property (Alexander I. Poltorak, Paul J. Lerner)
- Highlight on Page 25 | Added on Friday, 25 November 11 10:53:36 Greenwich Mean Time

commentators (a euphemism for prolific writers with little experience
==========
Essentials of Licensing Intellectual Property (Alexander I. Poltorak, Paul J. Lerner)
- Highlight on Page 26 | Added on Friday, 25 November 11 10:54:29 Greenwich Mean Time

我试图去掉“Essentials”和“Time”之间的所有内容。我现在正在玩的正则表达式如下所示:

Essentials([^,]+)Time

但显然是行不通的:

http://rubular.com/r/gwSJFgOQai

非常感谢对此 nuby 的任何帮助!

最佳答案

您需要使 . 匹配换行符的/m 修饰符:

/Essentials(.*?)Time/m

看到它在这里工作: http://rubular.com/r/qgmkWnLzW6

关于ruby - ruby 中的多行正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8304787/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com