【问题标题】:Sublime Text regex to remove line breaks from a selection?崇高文本正则表达式从选择中删除换行符?
【发布时间】:2016-01-04 20:07:43
【问题描述】:

我无法找出 Sublime Text 正则表达式来从选择中删除换行符。

上下文是我正在格式化教科书测试库以通过online Blackboard quiz generator 生成 Blackboard 测验池。这是一个示例问题。

25.   An increase in which of the following will increase the current value of a stock according to the dividend growth model?
I. dividend amount
II. number of future dividends, provided the current number is less than infinite
III. discount rate
IV. dividend growth rate 
A.    I and II only
B.    III and IV only
C.    I, II, and III only
*D.    I, II, and IV only
E.    I, II, III, and IV

我想删除罗马数字部分中的换行符,以便问题位于一行,每个答案(即 A 到 E)位于单独的一行。这是所需的输出。

25.   An increase in which of the following will increase the current value of a stock according to the dividend growth model? I. dividend amount II. number of future dividends, provided the current number is less than infinite III. discount rate IV. dividend growth rate 
A.    I and II only
B.    III and IV only
C.    I, II, and III only
*D.    I, II, and IV only
E.    I, II, III, and IV

对于 CTRL-J 的案例来说,这很容易,但我想要一个可扩展的解决方案,因为其中一些文件非常大。我也在使用RegReplace 来节省时间。

有没有办法使用 Sublime Text 正则表达式来做到这一点?我可以找到带有/^[0-9]{1,3}\..*?IV/s 的块(我在RegReplace 中使用dotall 选项在.* 中包含换行符),但我不知道如何删除换行符。

【问题讨论】:

    标签: regex sublimetext3 sublimetext


    【解决方案1】:

    我假设你没有得到 > 99 的罗马数字:

    \n(?=[IVXL])
    

    您匹配新行,后跟IVXL 之一(但不匹配实际数字)。替换为空格。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 2019-01-25
      • 2013-07-11
      • 2017-10-22
      相关资源
      最近更新 更多