Jump to content

search string in list


Recommended Posts

Hi all,



I want search a string in list using lisp can any body help me.


ex (setq a (list "1" "2" "3"))

now i want to search "2" in a list.


thank you

Link to comment
Share on other sites

just pass the list and search string to function




(defun c:test(/ a yes)

(setq a (list "1" "2" "3"))

(setq yes (searchstring a "2"))

(if(= yes t)

(prompt "found")

(prompt "Not found")






(defun searchstring(searchlist search / sealen sea anwser str)

(setq sealen (length searchlist))

(setq sea 0)

(setq anwser nil)


(setq str (nth sea searchlist))

(if(= (strcase search)(strcase str))


(setq anwser t)



(if(= anwser t)

(setq sea sealen)


(setq sea (+ 1 sea))




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...