WCMATCH patterns

Discussion in 'AutoCAD' started by SixFeet6, Dec 1, 2004.

  1. SixFeet6

    SixFeet6 Guest

    Hi guys,

    How do I define a pattern for WCMATCH giving the following :

    A string may only contain the single characters of the following list V,E,T,D,B,S,L,F

    ex "VS" = ok because V and S are in the list
    "BM" is wrong because M is not in the list
    "B8" is wrong because 8 is not in the list

    I can't find how to create the pattern,

    help appreciated !

    thx,

    6f6
     
    SixFeet6, Dec 1, 2004
    #1
  2. SixFeet6

    Alaspher Guest

    If all your strings always contain only 2 characters then is possible:
    Code:
    (wcmatch "VS" "[VETDBSLF][VETDBSLF]")
    Regards
     
    Alaspher, Dec 1, 2004
    #2
  3. SixFeet6

    SixFeet6 Guest

    It can contain 3 4... you name it.
     
    SixFeet6, Dec 1, 2004
    #3
  4. SixFeet6

    Alaspher Guest

    It can contain 3 4... you name it.

    then
    Code:
    (= "" (vl-string-trim "VETDBSLF" "VS"))
     
    Alaspher, Dec 1, 2004
    #4
  5. Based on your problem statement I'd use a while loop to step through the
    character positions and test each position individually. The other
    approach would be to do a global test for a character not in
    "V,E,T,D,B,S,L,F".

    Martin
     
    Martin Shoemaker, Dec 1, 2004
    #5
  6. SixFeet6

    BillZ Guest

    SixFeet6,

    Is this workable?

    Code:
    ;;12/01/04 Bill Zondlo
    ;;Program to search string for matching characters.
    ;;stringtest is string with valid characters..
    ;;stringmat is string to test.
    ;;returns T if all characters in stringmat are in test string.
    ;;
    (defun matchchars (stringtest stringmat / )
    (setq stringmat (vl-string->list stringmat)
    stringmat (mapcar '(lambda (x)(chr x)) stringmat)
    )
    (apply '= (mapcar '(lambda (x)(wcmatch stringtest (strcat "*" x "*"))) stringmat))
    )
    

    Bill
     
    BillZ, Dec 1, 2004
    #6
  7. SixFeet6

    SixFeet6 Guest

    thx,

    But...

    the wildcard is a parameter I want to save in an ascii file i use as reference.

    The routine i want to use it for verifies entities based on a ascii file.

    ex. off the ascii file

    *POLYLINE
    layer,linetype,linewieght, closed(1/0),color....
    *TEXT
    layer,color,linetype, height,width,text .....

    where I want to use text as the parameter what value for the text is allowed. when I place * anythings allowed.




    6f6
     
    SixFeet6, Dec 1, 2004
    #7
  8. SixFeet6

    BillZ Guest

    6f6,

    Command: (matchchars "TERHR8FGS" "*")
    T

    Bill
     
    BillZ, Dec 1, 2004
    #8
  9. SixFeet6

    BillZ Guest

    I had to fix the previous version because if none of the characters matched, matchchars returned T also.

    Code:
    ;;12/01/04 Bill Zondlo
    ;;Program to search string for matching characters.
    ;;stringtest is string with valid characters..
    ;;stringmat is string to test.
    ;;returns T if all characters in stringmat are in teststring.
    ;;
    ;;
    (defun matchchars (stringtest stringmat / result stringmat)
    (setq stringmat (vl-string->list stringmat)
    stringmat (mapcar '(lambda (x)(chr x)) stringmat) dd stringmat cc stringtest
    result (mapcar '(lambda (x)(wcmatch stringtest (strcat "*" x "*"))) stringmat)
    )
    
    (if (not (member 'T result))
    nil
    (apply '= result)
    )
    )
    
    Sorry for any inconvenience.

    Bill
     
    BillZ, Dec 1, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.