我正在尝试使用CL-PPCRE库来解决这个简单的Perl代码:
if (/\p{Space}/){
print "This string has some spaces\n";
}我是CL-PPCRE的新手,并尝试过:
(scan "\\p{\\#Space}" "The String has some white spaces");我收到一个错误,说属性#/Space不存在。
我怎样才能执行一个等价的函数?
发布于 2015-03-26 00:03:38
perl regexp /\p{Space}/匹配的不仅仅是“”。cf \p{} docs
一种方法是只使用\s表达式:
(cl-ppcre:scan "\\s" (format nil "hi~Cthere" #\return))要使用整个unicode Space类,请执行以下操作:
(ql:quickload :cl-unicode)
(cl-ppcre:scan "\\p{Space}" (format nil "hi~Cthere" #\return))请参阅CL-PPCRE文档中的Unicode properties。
发布于 2015-03-25 22:58:54
cl-ppcre库不要求您(至少在空间上)使用任何特殊常量。
(if (cl-ppcre:scan " " "alle meine entchen")
(FORMAT T "Does have spaces~%")
(FORMAT T "Does not have spaces~%"))
> Does have spaces
(if (cl-ppcre:scan " " "allemeineentchen")
(FORMAT T "Does have spaces~%")
(FORMAT T "Does not have spaces~%"))
> Does not have spaces就能达到目的。
https://stackoverflow.com/questions/29258819
复制相似问题