Search code examples
common-lispclisp

Learning clisp regexp


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?


Solution

  • 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)