saunambon654 Posted June 5, 2023 Share Posted June 5, 2023 mhupp, I think you forgot cases for special letter, be like @ *#. Quote Link to comment Share on other sites More sharing options...
mhupp Posted June 5, 2023 Share Posted June 5, 2023 (edited) Tech you don't need to split up numbers and letters. But I just liked how it looked. so you don't really even need to test for anything. The lisp below just puts each char in brackets and works the same. ;;----------------------------------------------------------------------------;; ;; Generate a text search that ignores Case Senesitivity. ;; saunambon654, Lee Mac, mhupp ;; https://www.cadtutor.net/forum/topic/39880-case-sensitivity/#comment-618863 ;; (ssget "X" (list '(0 . "TEXT") (cons 1 (IC "Floor9")))) ;; (ssget "X" '((0 . "TEXT") (1 . "[Ff][Ll][Oo][Oo][Rr][99]"))) (defun IC (str1 / str2 i) (if (= (type str1) 'STR) (progn (setq str2 "" i 1) (repeat (strlen str1) (setq x (substr str1 i 1)) (setq str2 (strcat str2 "[" (strcase x) (strcase x T) "]")) (setq i (1+ i)) ) ) ) str2 ) So this would generated (ssget "X" '((0 . "TEXT") (1 . "[Ff][Ll][Oo][Oo][Rr][99]"))) It would find all values for Floor9, but not Floor99. Edited June 5, 2023 by mhupp Quote Link to comment Share on other sites More sharing options...
saunambon654 Posted June 5, 2023 Share Posted June 5, 2023 1 minute ago, mhupp said: Tech you don't need to split up numbers and letters. But I just liked how it looked. so you don't really even need to test for anything. The lisp below just puts each char in brackets and works the same. ;;----------------------------------------------------------------------------;; ;; Generate a text search that ignores Case Senesitivity. ;; saunambon654, Lee Mac, mhupp ;; https://www.cadtutor.net/forum/topic/39880-case-sensitivity/#comment-618863 ;; (ssget "X" (list '(0 . "TEXT") (cons 1 (IC "Floor9")))) ;; (ssget "X" '((0 . "TEXT") (1 . "[Ff][Ll][Oo][Oo][Rr][99]"))) (defun IC (str1 / str2 i) ;ignore case (if (= (type str1) 'STR) (progn (setq str2 "" i 1) (repeat (strlen str1) (setq str2 (strcat str2 "[" (strcase x) (strcase x T) "]"))) (setq i (1+ i)) ) ) ) str2 ) So this would generated (ssget "X" '((0 . "TEXT") (1 . "[Ff][Ll][Oo][Oo][Rr][99]"))) It would find all values for Floor9, but not Floor99. Of course you could do it, we just find the best way. If your string is long (hundreds of letters) it will be effect to speed calculation. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 5, 2023 Share Posted June 5, 2023 Here's another way to write it - (defun casesensitivity ( s ) (vl-list->string (apply 'append (mapcar '(lambda ( a b ) (if (= a b) (list a) (list 91 a b 93))) (vl-string->list (strcase s)) (vl-string->list (strcase s t)) ) ) ) ) As for combinations, maybe something like this - (defun combinations ( s / foo ) (defun foo ( u l ) (if (cdr u) (append (mapcar '(lambda ( x ) (cons (car u) x)) (foo (cdr u) (cdr l))) (mapcar '(lambda ( x ) (cons (car l) x)) (foo (cdr u) (cdr l))) ) (list u l) ) ) (mapcar 'vl-list->string (foo (vl-string->list (strcase s)) (vl-string->list (strcase s t)) ) ) ) _$ (length (combinations "floor")) 32 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.