我在看一條線我編打開的文件,並顯示與.p
:非貪婪正則表達式匹配
First sentence. Another. One. Text continues
現在我想用replacement.
替換字符串First sentence.
但是,命令
.s/.*\./replacement./
作用在貪婪方式,即,它取代First sentence. Another. One.
通過replacement
,而不是強制根據需要t First sentence.
。
如何在ed中做非貪婪替換?
這已被問了很多次。提示:非貪婪的匹配(如'。*?')是你的朋友。在這種情況下更好的是一個排他字符類,比如'[^。] *'。 –