1. Login to Give a bone

## 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. Login to Give a bone

## 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 "
)
)
)
)
(princ)
)```

3. Login to Give a bone

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

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

4. Login to Give a bone

## 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 "*[:-@]*"))
)
)```
Originally Posted by ACE769734
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.

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

5. Login to Give a bone

## Re: Problems with wcmatch

Originally Posted by ACE769734
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.

#### Posting Permissions

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