Trim curly braces from string

2019-07-17 14:48发布

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条回答
爷的心禁止访问
2楼-- · 2019-07-17 15:47
CL-USER 13 > (string-trim '(#\{ #\}) "{1991-05-13}")
"1991-05-13"

CL-USER 14 > (string-trim "{}" "{1991-05-13}")
"1991-05-13"
查看更多
登录 后发表回答