wcmatch function enables applications to compare a string to a wild-card pattern. You can use this facility when you build a selection set (in conjunction with ssget) and when you retrieve extended entity data by application name (in conjunction with entget).
Thewcmatch function compares a single string to a pattern. The function returns T if the string matches the pattern, and nil if it does not. The wild-card patterns are similar to the regular expressions used by many system and application programs. In the pattern, alphabetic characters and numerals are treated literally; brackets can be used to specify optional characters or a range of letters or digits; a question mark (?) matches a single character; an asterisk (*) matches a sequence of characters; and, certain other special characters have special meanings within the pattern. When you use the * character at the beginning and end of the search pattern, you can locate the desired portion anywhere in the string.
Thematchme has been declared and initialized:
In the following examples, a string variable called_$ (setq matchme "this is a string - test1 test2 the end")
"this is a string - test1 test2 the end"
matchme begins with the four characters "this":
The following code checks whether or not_$ (wcmatch matchme "this*")
T
wcmatch returns T if matchme contains "test4", "test5", "test6" (4-6), or "test9" (note the use of the * character):
The following code illustrates the use of brackets in the pattern. In this case,_$ (wcmatch matchme "*test[4-69]*")
nil
wcmatch returns nil because matchme does not contain any of the strings indicated by the pattern.
In this case,However,
_$ (wcmatch matchme "*test[4-61]*")
T
true because the string contains "test1".
returnsT if matchme equals "ABC", or if it begins with "XYZ", or if it ends with "end".
The pattern string can specify multiple patterns, separated by commas. The following code returns_$ (wcmatch matchme "ABC,XYZ*,*end")
T