0

I am trying to find the number of times that one string is found in another string. I tried using (string= "x" "xyzx"), but of course that stops after the first match. If I put this into a loop, how would I define how to escape? Is there a way to specify that the end of the string has been reached? Is there a better way to do this? Thanks...

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Duoas
0

I don't know Lisp, but I do know Scheme. Write yourself a little recursive function that does the job. I would use an index into the string to keep the original string reference (instead of recursively operating on copies of substrings). When you run out of string, then you've found all the matches.

You might find the stuff at the CL Cookbook useful. Particularly the (search ...) function.

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.