See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: Problems with wcmatch

  1. #1
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Problems with wcmatch

    I want to test a 4 character test string where each character can be an upper-case letter or a number.

    (wcmatch "ABCD" "[A-Z#][A-Z#][A-Z#][A-Z#]") returns T as expected
    (wcmatch "aBCD" "[A-Z#][A-Z#][A-Z#][A-Z#]") returns nil as expected
    (wcmatch "1BCD" "[A-Z#][A-Z#][A-Z#][A-Z#]") returns nil for some unknown reason

    I also tried "[A-Z,#][A-Z,#][A-Z,#][A-Z,#]" and "[#A-Z][#A-Z][#A-Z][#A-Z]" but these didn't work either.

    Can anybody tell me what I'm doing wrong?

    Any help is greatly appreciated.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Problems with wcmatch

    Code:
    (defun c:FOO (/ _match)
    
      (defun _match (string)
        (or
          (wcmatch string "[A-Z][A-Z][A-Z][A-Z]")                           ; AAAA
          (wcmatch string "#[A-Z][A-Z][A-Z]")                               ; #AAA
          (wcmatch string "[A-Z]#[A-Z][A-Z]")                               ; A#AA
          (wcmatch string "[A-Z][A-Z]#[A-Z]")                               ; AA#A
          (wcmatch string "[A-Z][A-Z][A-Z]#")                               ; AAA#
        )
      )
    
      (foreach x '("ABCD" "aBCD" "1BCD")
        (prompt (strcat "\n\""
                        x
                        "\" : Match "
                        (if (_match x)
                          "found "
                          "NOT found "
                        )
                )
        )
      )
      (princ)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2018-06
    Posts
    5
    Login to Give a bone
    0

    Default Re: Problems with wcmatch

    That code does not meet the OP's conditions.
    There could be more that one numeric digit in the four digit string. The total number of possibilities are 16 combinations, not 5.

    The answer is:

    Code:
    (wcmatch "ABCD" "[1-Z][1-Z][1-Z][1-Z]")

  4. #4
    Member
    Join Date
    2018-06
    Posts
    5
    Login to Give a bone
    1

    Default Re: Problems with wcmatch

    A quick revision, check out the ascii table and it will search for the characters 0 to Z except for : to @.

    Code:
    (defun _match (str)
      (and 
        (wcmatch str "[0-Z][0-Z][0-Z][0-Z]")
        (not (wcmatch str "*[:-@]*"))
      )
    )
    Quote Originally Posted by ACE769734 View Post
    That code does not meet the OP's conditions.
    There could be more that one numeric digit in the four digit string. The total number of possibilities are 16 combinations, not 5.

    The answer is:

    Code:
    (wcmatch "ABCD" "[1-Z][1-Z][1-Z][1-Z]")

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: Problems with wcmatch

    Quote Originally Posted by ACE769734 View Post
    A quick revision, check out the ascii table and it will search for the characters 0 to Z except for : to @.

    Code:
    (defun _match (str)
      (and 
        (wcmatch str "[0-Z][0-Z][0-Z][0-Z]")
        (not (wcmatch str "*[:-@]*"))
      )
    )
    Well done, Ace.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. wildcarding tblobjname BLOCK with wcmatch?
    By mnelson.92099 in forum AutoLISP
    Replies: 1
    Last Post: 2007-12-12, 07:08 PM
  2. Problems with element not showing
    By Chad Smith in forum Revit Architecture - Families
    Replies: 3
    Last Post: 2007-02-19, 11:59 AM
  3. List of problems after my first big work with Revit
    By overcaffeined1745 in forum Revit Architecture - General
    Replies: 12
    Last Post: 2004-02-04, 04:43 AM
  4. Curtain wall problems
    By Martin P in forum Revit Architecture - General
    Replies: 11
    Last Post: 2003-10-01, 09:36 PM
  5. Problems w/ linked drawings
    By BomberAIA in forum Revit Architecture - General
    Replies: 3
    Last Post: 2003-08-26, 12:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •