Wcmatch wtih wildcards

Wcmatch wtih wildcards

Anonymous
Not applicable
960 Views
2 Replies
Message 1 of 3

Wcmatch wtih wildcards

Anonymous
Not applicable

Hello all, 

Thank you for considering to answer my question here. 

So i have many variations of "structure IDs" this one in particular is "stk 55[3C] P1"

I have the structure of a program to go search all cogo point description and find my structure number ("stk 55[3C] P1")

However, I am having issues on the matching part. 

The names varry and could have [] or - or _ so i tried using LeeMacs Code but cant get it to work. 

I have attached the code i have been working on as well- its a little messy as i am still working on it 

 

http://www.lee-mac.com/escapewildcards.html - here is the like to lee macs code i waas trying to use 

 

 

 

;; Escape Wildcards  -  Lee Mac
;; Escapes wildcard special characters in a supplied string

(defun LM:escapewildcards ( str )
    (if (wcmatch str "*[-#@.*?~`[`,]*,*`]*")
        (if (wcmatch str "[-#@.*?~`[`,]*,`]*")
            (strcat "`" (substr str 1 1) (LM:escapewildcards (substr str 2)))
            (strcat     (substr str 1 1) (LM:escapewildcards (substr str 2)))
        )
        str
    )
)



(LM:escapewildcards "stk 55[3C] P1" )
(WCMATCH  "stk 55[3C] P1"(LM:escapewildcards "55[3C]"))

 

Escentally would this not work for matching up with any string to any pattern?

what am i doing wrong and what could be the solution?

0 Likes
Accepted solutions (1)
961 Views
2 Replies
Replies (2)
Message 2 of 3

hak_vz
Advisor
Advisor
Accepted solution

Try this

 

(wcmatch  "stk 55[3C] P1" (strcat "*" (LM:escapewildcards "55[3C]") "*"))

 

Also use STRCASE function to change letter case since WCMATCH comparison is case-sensitive, so uppercase and lowercase characters must match.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thats amazing, it works exactly how I anticipated! 

 

Thank you so much for your help!