Thursday, 1 September 2022

How can I use Lisp subseq using colon (or other non-alphanumeric characters)?

I need to extract a substring from a string; the substring is enclosed by ":" and ";". E.g.

:substring;

But with Lisp (SBCL), I'm having trouble extracting the substring. When I run:

(subseq "8.I:123;" : ;)

I get:

#<THREAD "main thread" RUNNING {1000510083}>:
  illegal terminating character after a colon: #\

    Stream: #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {1000025923}>

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-IMPL::READ-TOKEN #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {1000025923}> #\:)

I've tried preceding the colon and semicolon with \ but that throws a different error. Can anyone advise? Thanks in advance for the help!



from How can I use Lisp subseq using colon (or other non-alphanumeric characters)?

No comments:

Post a Comment