Author Topic: wcmatch question  (Read 1827 times)

0 Members and 1 Guest are viewing this topic.

csgoh

  • Newt
  • Posts: 176
wcmatch question
« 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.

kpblc

  • Bull Frog
  • Posts: 396
Re: wcmatch question
« Reply #1 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
Sorry for my English.

Lee Mac

  • Seagull
  • Posts: 12892
  • London, England
Re: wcmatch question
« Reply #2 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> "###-###")

Joe Burke

  • Guest
Re: wcmatch question
« Reply #3 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


Lee Mac

  • Seagull
  • Posts: 12892
  • London, England
Re: wcmatch question
« Reply #4 on: June 17, 2010, 07:12:03 AM »
Thanks Joe, I need to brush up on my Wildcard Strings...


csgoh

  • Newt
  • Posts: 176
Re: wcmatch question
« Reply #6 on: June 17, 2010, 10:15:45 AM »
thanks, guys

Lee Mac

  • Seagull
  • Posts: 12892
  • London, England
Re: wcmatch question
« Reply #7 on: June 17, 2010, 12:26:06 PM »
Thanks Alan, those are great  8-)