Я пытаюсь сопоставить последний символ в конце каждой строки (многострочная текстовая строка) в Clojure. Вот пример текста:
"Possible values:
copy: A copy of the source item is made at the new location.
move: An item is moved to a new location.
link: A link is established to the source at the new location.
none: The item may not be dropped."
Я пробовал #"\n"
но это соответствует только новой строке.
Используйте #"\n|$"
; \n
чтобы соответствовать всем новым строкам, кроме последнего, и $
чтобы соответствовать последнему.
user=> (print (clojure.string/replace text #"\n|$" "...\n"))
Possible values:...
...
copy: A copy of the source item is made at the new location....
move: An item is moved to a new location....
link: A link is established to the source at the new location....
none: The item may not be dropped....
(?m).$
? ...........