I want to check if a user input a word or a number. And I write the function look like this:
(defun check-input (arg)
"description"
(interactive "senter arg: ")
(setq isnum (string-match "\\'[0-9]+\\'" arg))
(if isnum
(message "INPUT is number ")
(message "INPUT is string ")))
But every time I enter whether the a number of a word, it just show "Input is string". Can you help me where did I go wrong. Thanks you very much
string-match
. 2. Usestring-match-p
. 3. Bindisnum
withlet
, instead of using a global variable - or just put the test sexp directly in yourif
(no variableisnum
).