我正在使用下面的代码来中断与模式匹配的行:
找什么:
([0-9]) ([A-Z])
用。。。来代替: \1\n\2
以便 …
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3
……变成
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
但是我必须手动替换每个实例,因为我有数万行,如果我使用全部替换,它会在我不想破坏的区域断行。
具体来说,我想在字符串“zyxl”和“1st Dam”之间的区域中打断与模式匹配的行,但不打断任何与“1st Dam”和“zyxl”之间的模式匹配的行
“查找内容”中的以下代码将找到我想要断行的区域:
(?s)^\t*zyxl(.|\r\n)*?1st Dam
这段代码将找到我不想破坏代码的区域:
(?s)^\t*1st Dam (.|\r\n)*?zyxl
有没有办法,或者通过结合这些方法,或者以其他方式,重新排列文本,以便……
zyxl
QUEENB BLUE CHIP
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3 Grassbed 2,1:59.1
1st Dam
RICHESSE OBLIGE Varenne. 13 wins, 2 thru 5. This is her first foal.
zyxl
VENERATE
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3 Grassbed 2,1:59.1
1st Dam
RICHESSE OBLIGE 13 wins, 2 thru 5. This is her first foal.
Zyxl
……变成
zyxl
QUEENB BLUE CHIP
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
Grassbed 2,1:59.1
1st Dam
RICHESSE OBLIGE Varenne. 13 wins, 2 thru 5. This is her first foal.
zyxl
VENERATE
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
Grassbed 2,1:59.1
1st Dam
RICHESSE OBLIGE 13 wins, 2 thru 5. This is her first foal.
zyxl
提前感谢您的时间和帮助。
假设在 line 之前有“zyxl”
VENERATE
。(?:zyxl|\G)(?:(?!1st Dam).)*?\d\K\h+(?=[A-Z])
\n
或\r\n
对于 Windows EOL. matches newline
解释:
截图(之前):
截图(之后):