Subject: Re: Parsing a simple string
From: Erik Naggum <erik@naggum.no>
Date: 1997/03/11
Newsgroups: comp.lang.lisp
Message-ID: <3067028325983943@naggum.no>


* Hrvoje Niksic
| I'm doing my first steps in CL programming, and have found an obstacle.
| I have a file of the following format:
| 
| string number
| ...
| 
| That is, each lines looks something like "foo 5" (the delimiter is one
| SPC character).  I know how to read lines from the file using
| `read-line', but I'd like to parse the string as to get the string "foo"
| and number 5.  What's the best way to do it?  Any pointers?

since the delimiter is a single space, let's exploit that.
(position #\Space <input-line>) yields its position.
(subseq <input-line> 0 <position>) yields the string.
(parse-integer <input-line> :start <position>) yields the number.

#\Erik
-- 
how to beat Microsoft, death, and poverty: in July 1994, there were more
references to my name (3039) in gopherspace than to Microsoft (2557), death
(2530), and poverty (2410).  (http://veronica.sonoma.edu:8001/top1000.html)