Re: match()

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu