Dear list, I have this sample: \starttext \startluacode a = "asdfasd123" b = a:match("%d+") context(b) c = "123" context(c) if b==c then context("yes") else context("no") end function document.numbers_only(str) context(str:gsub("[%a%p]", "")) end function document.only_numbers(str) context(str:match("%d+")) end function document.compare_strings(one, two) if one == two then context("Yes") else context ("No") end end \stopluacode \unexpanded\def\numbersonly#1% {\ctxlua{document.numbers_only("#1")}} \unexpanded\def\onlynumbers#1% {\ctxlua{document.only_numbers("#1")}} \unexpanded\def\comparestrings#1#2% {\ctxlua{document.compare_strings("#1", "#2")}} \def\rstring{abc123} \numbersonly{abc123} \onlynumbers{abc123} \doifelse{\numbersonly{\rstring}}{abc123}{yes}{no} \doifelse{abc123}{\onlynumbers{\rstring}}{yes}{no} \comparestrings{\numbersonly{\rstring}}{123} \comparestrings{123}{123}, \comparestrings{1}{123} \stoptext I need to extract the digits from a string, which actually comes from the "--arguments" option in the command line. I need to compare the string with real numbers. But for some reason unknown to me, this is more complex than I thought. Could anyone explain me what I am doing wrong? Many thanks for your help, Pablo -- http://www.ousia.tk
participants (1)
-
Pablo Rodriguez