[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: validation function
- From: "Aaron Brown" <aaron-lua@...>
- Date: Fri, 26 Aug 2005 09:55:21 -0400
Antero Vipunen wrote:
> I follow `escape magic characters everywhere' convention
> (even if it is not necessary).
This is a respectable policy. I don't follow it because I
find it easy to remember that only a select few characters
are magic within square brackets (this is also how POSIX
regular expressions work). I do, however, usually follow
the policy of %-escaping nonmagical punctuation so I don't
have to remember Lua's (admittedly small) set of magic
characters, and also as a form of future-proofing.
On a similar topic, here's a quiz about a silly little
"Four score XXX seven years ago"
What would you like to replace "XXX" with?
local Input = io.read("*l")
Input = string.gsub(Input, "\n$", "")
local NewStr = string.gsub("Four score XXX seven years ago",
Under what circumstance will the program either disobey the
user's request or or actually error out? What's the fix?
(Things don't work if the user enters a null byte, but
I'm interested in something else.)