Jump to content

WCMATCH ignore all Wild-card characters except *


Emmanuel Delay

Recommended Posts

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

Link to comment
Share on other sites

(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 by mhupp
Link to comment
Share on other sites

Link to comment
Share on other sites

19 minutes ago, marko_ribar said:

 

Ah, interesting.

At first glance it does the opposite, but I'll see if this can help me.

 

Link to comment
Share on other sites

You have to escape ( ` ) the ( , ) in your pattern: (wcmatch "EV_003_VES_-0,5" "EV_00*_VES_-0`,5")

Edited by ronjonp
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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 by Jonathan Handojo
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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

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.

Guest
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...