簡體   English   中英

Clojure:我可以用什么正則表達式來檢測多行字符串中一行的最后一個字符?

[英]Clojure: What regular expression can I use to detect the last character of a line in a multi-line string?

我想在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....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM