On Thu, Jan 15, 2009 at 8:55 AM, Simen Kjaeraas <simen.kja...@gmail.com> wrote:
> munch("bar-baz", "-");
>
> returns "". Is there a way to do this apart from writing my own function?

I think you've got the behavior of munch backwards.  It will eat any
characters that _are_ in the pattern string.  Since 'b' is not in the
string "-", it returns immediately, since it didn't munch anything.

If you're looking for something to split up a string into tokens, you
could either use find or split; the former could be used to slice the
string one piece at a time, and the latter does it all at once at the
expense of allocating a new array to put the slices in.

Reply via email to