2
votes

Trying to do my first steps in lisp:

I'm finding the following behaviour that, AFAIK, is incorrect.

[185]> (if (regexp:match "[:alnum:]" "2" :extended t) t nil)
NIL
[186]> (if (regexp:match "[:alnum:0-9]" "2" :extended t) t nil)
T

I understand :alnum: should include digits, but, apparently it doesn't!

What I'm doing wrong?

1
The engine probably doesn't support [:alnum:]. You could use [A-Za-z0-9_] instead. \w might also work (at least if you switch to cl-ppcre). - jkiiski

1 Answers

7
votes

The syntax for character classes is "[:alnum:]", including the square brackets. So if you want to match, you have to write it like this:

(regexp:match "[[:alnum:]]" "2" :extended t)