Hi, I'm new to LISP and I have a question I suspect stems from my C-eish ways! I have a string "A + (B+C)*(A'+D)" I need to be able to have that tokenized. I want the first level to include the two elements "A" and "(B+C)*(A'+D)". And then I want to split the second string from the the middle multiplication sign etc... I thought I can achieve this by searching for the "+" and "*", but I haven't been able to find a string-search function in common-lisp (something like strstr in C, I think). Is there such a function that can search strings and give me indexes based on character positions? I know that strings are just arrays, but I couldn't find an array function that will let me access all BUT the first element (ie I could build my own string manipulation routines). Any pointers/suggestions would be greatly appreciated! Thanks, Michael Abd-El-Malek
* Michael Abd-El-Malek | Is there such a function that can search strings and give me indexes | based on character positions?
see the functions SEARCH, FIND, POSITION. they operate on sequences, which forms the supertype of list, vector, array, and string. you won't find all that many functions specific to strings in Common Lisp, because most of the time, they're useful to all sorts of sequences. this also means you use SUBSEQ to extract substrings, and COPY-SEQ to copy strings.
Erik Naggum wrote: > * Michael Abd-El-Malek > | Is there such a function that can search strings and give me indexes > | based on character positions?
> see the functions SEARCH, FIND, POSITION. they operate on sequences, > which forms the supertype of list, vector, array, and string. you won't > find all that many functions specific to strings in Common Lisp, because > most of the time, they're useful to all sorts of sequences. this also > means you use SUBSEQ to extract substrings, and COPY-SEQ to copy strings.