TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: csgoh on June 17, 2010, 02:57:38 AM

Title: wcmatch question
Post by: csgoh on June 17, 2010, 02:57:38 AM
I am having problem with the function wcmatch.
For eg I have a string "123-567" how to use wcmatch to test for the "-" character.
Title: Re: wcmatch question
Post by: kpblc on June 17, 2010, 03:01:47 AM
Code: [Select]
_$ (setq str "1234-5678")
"1234-5678"
_$ (WCMATCH str "*-*")
T
_$ (VL-STRING-SEARCH "-" str)
4
_$ (VL-STRING-SEARCH "a" str)
nil
Title: Re: wcmatch question
Post by: Lee Mac on June 17, 2010, 05:16:46 AM
As posted by kpblc, you could use:

Code: [Select]
(wcmatch <string> "*-*")
If you know there are definitely going to be three numbers each side, you could also use:

Code: [Select]
(wcmatch <string> "###-###")
Title: Re: wcmatch question
Post by: Joe Burke on June 17, 2010, 06:55:41 AM
Lee,

Command: (setq str1 "1234-5678")
"1234-5678"
Command: (wcmatch str1 "[0-9]*-[0-9]*")
T

Command: (setq str2 "a14-5678")
"a14-5678"
Command: (wcmatch str2 "[0-9]*-[0-9]*")
nil

Command: (setq str3 "1-2")
"1-2"
Command: (wcmatch str3 "[0-9]*-[0-9]*")
T

Title: Re: wcmatch question
Post by: Lee Mac on June 17, 2010, 07:12:03 AM
Thanks Joe, I need to brush up on my Wildcard Strings...
Title: Re: wcmatch question
Post by: CAB on June 17, 2010, 09:34:10 AM
More info here

http://www.theswamp.org/index.php?topic=28210.0
http://www.theswamp.org/index.php?topic=5004.msg60485#msg60485
http://www.theswamp.org/index.php?topic=28210.msg337978#msg337978
http://www.theswamp.org/index.php?topic=28210.msg337979#msg337979
http://www.theswamp.org/index.php?topic=27733.msg333229#msg333229
Title: Re: wcmatch question
Post by: csgoh on June 17, 2010, 10:15:45 AM
thanks, guys
Title: Re: wcmatch question
Post by: Lee Mac on June 17, 2010, 12:26:06 PM
Thanks Alan, those are great  8-)