Skip to content

o_num command object=$+setnum (.+)=([0 9]*): @va me=data: %1 = %

Luxembourg edited this page Mar 20, 2013 · 3 revisions

@set Command Object/DO_NUM = regexp

Then, '+setnum cookies=30' would set VA to "Data: cookies = 30". This eliminates your having to check to see if the player entered a number, since the regular expression matches only numbers. Furthermore, the '+' guarantees that there needs to be at least one character there, so a player can't enter '+setnum cookies=' or '+setnum =10' or similarly malformed input.

Also note that regexps are case-sensitive, but wildcard globbing is not. Some regular expression functions offer case-insensitive versions, some regexp can be made case-insensitive by putting (?i) at the start. Setting the CASE attribute flag is another way of selecting case-insensitivity.

Related Topics: regexp syntax

Clone this wiki locally