I am trying to match the last character at the end of each line (multi-line text string) in Clojure. Here is a sample text:
"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."
I tried #"\\n"
but that only matches a new line.
Use #"\\n|$"
; \\n
to match all newlines except the last one, and $
to match the last one.
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....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.