Searching a string for content, while populating a list.

Started by statik, February 13, 2006, 04:57:02 PM

Previous topic - Next topic

statik

I am wondering what the easiest, or most efficient way is to search a string for all occurances of X and populating a list with each occurance. I've come up with a few solutions to this, but I am not sure that they are as fast or easy as they could be. I'd like to do a (find) with some regex on a string and throw each found occurance into a list.



Any ideas?



NOTE: In addition, I could use some mad regex fu. I need to scoure html source for all links and throw them into a list. Has anyone solved this problem already?
-statik

Lutz

#1
This code from http://newlisp.org/DesignPatterns.html#text_processing">http://newlisp.org/DesignPatterns.html#text_processing in section "Scanning text"



(set 'page (get-url "http://www.nodep.nl/newlisp/index.html"))

(replace {href="(http://.*lsp)"} page (push $1 links) 0)


pushes all instances of a regex pattern on a list 'links'



Lutz