Dav*_*ker 6 regex text notepad++ geany
我有一个文本文件,每个段落都独占一行。有些段落在单词的开头被分割。例如:
Books are an effective way to
communicate across time, both from the past and into the future.
Run Code Online (Sandbox Code Playgroud)
我可以在搜索中使用正则表达式(regex),并在 Notepad++ 或 Geany 中替换它们,以在行的开头搜索小写字母,并将 \r\n (回车符+换行符)替换为空间。
问题是章节的副标题位于单词“or”之后,而单词“or”单独占一行。例如:
Chapter 3
The Importance of Reading
or
Literature is the most agreeable way of ignoring life
Run Code Online (Sandbox Code Playgroud)
使用该方法会将“或”行放在章节标题中,而不是单独一行。
我想要的是告诉正则表达式一行是否以小写字母开头以匹配它(用空格替换后面的 \r\n),但如果该行是“or\r\n”则不告诉正则表达式。
bob*_*ble 21
看起来您可以使用lookarounds \xe2\x80\x94搜索:
\n\\h*\\R(?=[a-z])(?!or$)\nRun Code Online (Sandbox Code Playgroud)\n并替换为空格。请参阅regex101 上的演示(右侧的说明)。
\n\n在 Notepad++ 的替换对话框中,确保选中[\xe2\x80\xa2] Match case和[\xe2\x80\xa2] Wrap around。
\n