Trim curly braces from string

风流意气都作罢 提交于 2019-12-24 01:24:25

问题


I am using a Prolog query in a Common Lisp program to get the date of birth from a knowledge base. The query returns the value formatted as {1991-05-13}, and I assign to this value on dob variable with setq: (setq dob {1991-05-13}). I want to use this date value in a new function which takes string, so I am trying to use write-to-string to convert dob to a string with (setq strdob (write-to-string dob)), but it returns

"{1991-05-13}"

I actually want:

"1991-05-13"

which lacks the curly braces. How could I trim the curly braces from the string?


回答1:


CL-USER 13 > (string-trim '(#\{ #\}) "{1991-05-13}")
"1991-05-13"

CL-USER 14 > (string-trim "{}" "{1991-05-13}")
"1991-05-13"


来源:https://stackoverflow.com/questions/20827038/trim-curly-braces-from-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!