从字符串修剪花括号 [英] Trim curly braces from string
问题描述
我在Common Lisp程序中使用Prolog查询来从知识库中获取出生日期.该查询返回格式为{1991-05-13}
的值,我使用setq
:(setq dob {1991-05-13})
将其分配给dob
变量.我想在使用字符串的新函数中使用此日期值,因此我尝试使用write-to-string
将dob
转换为带有(setq strdob (write-to-string dob))
的字符串,但它返回
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}"
我实际上想要:
"1991-05-13"
缺少花括号.如何修剪字符串中的花括号?
which lacks the curly braces. How could I trim the curly braces from the string?
推荐答案
CL-USER 13 > (string-trim '(#\{ #\}) "{1991-05-13}")
"1991-05-13"
CL-USER 14 > (string-trim "{}" "{1991-05-13}")
"1991-05-13"
这篇关于从字符串修剪花括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!