PDA

View Full Version : search string


odo
05-12-2005, 08:33 AM
I need to search in a file the line that satisfy my string request.
eg:
my string request "K25100"
read in a file that contain path of the file
result :
W:/cad1/K251/K251001
W:/cad1/K251/K251002
W:/cad1/K251/K251003
etc.
Next show me the results in OSD.
I try to make it, but my problem is to search the string row to row until end.
Can you help me please.
Thanks

Wolfgang
05-12-2005, 12:19 PM
(defun oli::ascii-file2str-list (filename)
(if (probe-file filename)
(let (list-of-lines line-of-file)
(with-open-file (in-stream filename :direction :input :if-does-not-exist nil)
(loop while (setf line-of-file (read-line in-stream nil)) do
(push (oli::sd-string-replace line-of-file (format nil "~A" (code-char 13)) "") list-of-lines)
) ;; end loop
) ;; end with-open-file
(reverse list-of-lines) ;; return lines in correct order
) ;; end let
(values NIL :file-not-found)
) ;; end if
) ;; end ascii-file2str-list
use is as it is.. or learn out of it.. or ask once more

But question:
do you want to get all lines matching your pattern, or just the frist one: so =mapcan= or =find= to be used?