Re: match()
- Posted by gertie at visionsix.com May 26, 2003
- 442 views
On 26 May 2003, at 17:07, Derek Parnell wrote: > > > On Mon, 26 May 2003 13:30:41 +0700, aku saya <akusaya at gmx.net> wrote: > > > > > match("", "something") shows an error > > first argument of match() must be a non-empty sequence > > > > I think it should return 1, because "" is a substring of "something", > > and is located in any position. > > > > So I don't have to check if the first argument is "", don't call > > match(). > > > > How do you think? > > One way of looking at this is to ask "Where does NOTHING first appear in > the string?". And there is no meaningful answer to that. > > To be consistent, I would have preferred that match() return zero,because > the empty string wasn't found in the target string. But because that too is > debatable, just disallowing it might be the best (unambiguous) way to handle > it. > > And if we look at it the way you suggested, "because "" ... is located in > any position" then any random number between 0 and the length of the target > string would be just as valid. I prefer it return zero also, simply because match("u","kat") also returns zero. Kat