在旁写中使用正则表达式(正则表达式) [英] Using regex (Regular Expressions) in Parenscript

查看:155
本文介绍了在旁写中使用正则表达式(正则表达式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试Parenscript。在尝试使用正则表达式功能时,得到了意外的输出。例如,参考手册显示:

I am trying out Parenscript. While trying to experiment with regex function, I get unexpected output. for example, the reference manual shows:

(regex "foobar")
    /foobar/;

(regex "/foobar/i")
    /foobar/i; 

但是在我的repl中,我得到一个错误,即未定义函数(parenscript:regex ..)。

However in my repl I get error that function (parenscript:regex..) is undefined.

The function parenscript:regex is undefined.
   [Condition of type undefined-function]

Restarts:
 0: [continue] Retry using regex.
 1: [use-value] Use specified function
 2: [retry] Retry SLIME REPL evaluation request.
 3: [*abort] Return to SLIME's top level.
 4: [abort] abort thread (#<thread "repl-thread" running {1002319B63}>)

Backtrace:
  0: (sb-impl::retry-%coerce-name-to-fun regex nil)
  1: (sb-int:simple-eval-in-lexenv (regex "foobar") #<NULL-LEXENV>)
  2: (eval (regex "foobar"))
 --more--

我尝试过将名称空间更改为cl-user,ps等,没有任何效果。 OTOH,只是为了检查,我尝试使用函数sin,random等,并且奏效了。我的意思是,在repl中键入(sin 0.1)会产生预期的输出。

I tried changing namespace to cl-user,ps, etc, nothing worked. OTOH, just for checking, I tried using functions sin, random, etc., and that worked. I mean, typing (sin 0.1) in repl yielded expected output.

任何帮助都会有很大帮助。

Any help will be of great help.

推荐答案

在SBCL中,读取-评估-打印循环:

In a SBCL read-eval-print-loop:

CL-USER> (in-package "PS")
#<PACKAGE "PARENSCRIPT">

PS> (ps (regex "foobar"))
"/foobar/;"

PS> (in-package "CL-USER")
#<package "COMMON-LISP-USER">

cl-user> (ps:ps (ps:regex "foobar"))
"/foobar/;"

PS:PS 是Parenscript编译器,如宏运算符。

PS:PS is the Parenscript compiler as a macro operator.

这篇关于在旁写中使用正则表达式(正则表达式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆