【发布时间】:2021-10-15 09:31:35
【问题描述】:
我正在尝试在与环视匹配的行的开头添加空格。这是一个示例文本:
This is my
first sentence
with 2 lines
that have to be indented.
This is my
second sentence
with 2 lines
that have to be indented.
这是我想要得到的输出:
This is my
first sentence
with 2 lines
that have to be indented.
This is my
second sentence
with 2 lines
that have to be indented.
我试过用这个环顾四周:
(?<=This is my)(.*?)(?=\nthat)
但是,我无法将行首与^ 匹配。也就是说,(?<=This is my)(^)(?=\nthat) 不起作用。
TIA!
【问题讨论】:
-
您使用哪种编程语言?
标签: regex regex-lookarounds regexp-replace