Emmanuel Delay Posted October 12, 2022 Posted October 12, 2022 Is there a way to make wcmatch not see the comma or minus-sign as a wild-card character? I only really need * as a wild-card character, the rest should be see as valid characters. I have blocks with an attribute like "EV_001_VES_-0,5" "EV_002_VES_-0,5" "EV_003_VES_-0,5" I want users to search for those blocks, and they get to do command GETBLOCK -> EV_00*_VES_-0,5 function GETBLOCK uses wcmatch. But commas, points, minus signs are in those strings. So for example, somehow this should return true. (wcmatch "EV_003_VES_-0,5" "EV_00*_VES_-0,5") Do I have to escape all these Wild-card characters listed here, or so? http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6754.htm Quote
mhupp Posted October 12, 2022 Posted October 12, 2022 (edited) (wcmatch "EV_003_VES_-0,5" (strcat "EV_00*_VES_-0" (chr 44) "5")) need the number for , this is prob the better option since chr 44 might be something else in a custom font (wcmatch "EV_003_VES_-0,5" "EV_00*_VES_-0`,5") ;this should also work --edit Quote Using Escape Characters with wcmatch To test for a wild-card character in a string, you can use the single reverse-quote character (`) to escape the character. Escape means that the character following the single reverse quote is not read as a wild-card character; it is compared at its face value. For example, to search for a comma anywhere in the string “Name”, enter the following: Edited October 12, 2022 by mhupp Quote
marko_ribar Posted October 12, 2022 Posted October 12, 2022 @Emmanuel Delay See if some of these links can help you... It is somewhat connected with (wcmatch) function and its functionality... https://www.cadtutor.net/forum/topic/74031-matching-pattern-of-two-strings https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/pbe-challenge-wcmatch-patterns/m-p/10963535/highlight/true#M427615 HTH., M.R. Quote
Emmanuel Delay Posted October 12, 2022 Author Posted October 12, 2022 19 minutes ago, marko_ribar said: @Emmanuel Delay See if some of these links can help you... It is somewhat connected with (wcmatch) function and its functionality... https://www.cadtutor.net/forum/topic/74031-matching-pattern-of-two-strings https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/pbe-challenge-wcmatch-patterns/m-p/10963535/highlight/true#M427615 HTH., M.R. Ah, interesting. At first glance it does the opposite, but I'll see if this can help me. Quote
ronjonp Posted October 12, 2022 Posted October 12, 2022 (edited) You have to escape ( ` ) the ( , ) in your pattern: (wcmatch "EV_003_VES_-0,5" "EV_00*_VES_-0`,5") Edited October 12, 2022 by ronjonp 1 1 Quote
Jonathan Handojo Posted October 12, 2022 Posted October 12, 2022 (edited) 6 hours ago, mhupp said: (wcmatch "EV_003_VES_-0,5" (strcat "EV_00*_VES_-0" (chr 44) "5")) need the number for , this is prob the better option since chr 44 might be something else in a custom font (wcmatch "EV_003_VES_-0,5" "EV_00*_VES_-0\,5") this should also work Wrong. AutoLISP does not use the backslash to escape wildcard characters. It is, as ronjonp has stated, the reverse quote. @Emmanuel Delay If you would like to escape all wildcard characters, take a page from Lee Mac's book and have a go using the iterative version of this. All the escape characters in that function is entailed in the list of numbers '(35 64 46 42 63 126 91 93 45 44). The asterisk has the ascii number of 42, therefore if you remove that from the list, that should escape everything except the asterisk, which is what you're after. For any other characters if you're unsure, just invoke (ascii ".") or (ascii ",") or the character you wish in the command line, and remove that number from the list. Edited October 12, 2022 by Jonathan Handojo 1 1 Quote
mhupp Posted October 12, 2022 Posted October 12, 2022 @Jonathan Handojo yeah, put it in the old (princ "EV_00*_VES_-0\,5") to test didn't read the one above about "Using Escape Characters with wcmatch" Quote
Emmanuel Delay Posted October 13, 2022 Author Posted October 13, 2022 12 hours ago, ronjonp said: You have to escape ( ` ) the ( , ) in your pattern: (wcmatch "EV_003_VES_-0,5" "EV_00*_VES_-0`,5") Ah yes. This solves it completely. Thanks. And thanks guys Quote
ronjonp Posted October 13, 2022 Posted October 13, 2022 8 hours ago, Emmanuel Delay said: Ah yes. This solves it completely. Thanks. And thanks guys Quote
mhupp Posted October 21, 2022 Posted October 21, 2022 (edited) Just hit me @BIGAL Could you use this with your Fillet lisp where your using the - instead of . Edited October 21, 2022 by mhupp Quote
BIGAL Posted October 22, 2022 Posted October 22, 2022 Mhupp using "," seemed to work and makes more sense. C12,34 (setq com (vl-string-translate "," "." (strcase (car com)))) Quote
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.