- Subject: Re: [slang-users] Multi-character delimiter for strchop()?
- From: "J.B. Nicholson-Owens" <jbn@xxxxxxxxxxxxxxx>
- Date: Sun, 05 Oct 2014 13:35:49 -0500
Manfred Hanke wrote:
Maybe you are looking for the following:
strtok("afoobfooc", "foo")
Unfortunately, no, and I'll try to illustrate why. But thanks for the
response!
strtok("afoobfooc", "foo") does return ["a","b","c"] as asked but so do
the following:
strtok ("afoooooobfooc", "foo")
strtok ("afbfooc", "foo")
strtok ("afobfooc", "foo")
strtok ("afoofbfooc", "foo")
strtok ("aofobfooc", "foo")
which is not the same the substring-based chopping I initially asked
about. According to what I initially asked about:
strchop ("afoooooobfooc", "foo", 0)
should return a 7-cell string array:
["a","o","o","o","o","b","c"]
because "foo" is the indicator of the chopping point. "foo" is not the
same as "foooooo" but both list the same set of characters -- "f" and
"o" which means strtok() is behaving as
http://www.jedsoft.org/slang/doc/html/slangfun-5.html#strtok describes.
Thinking about this beyond what I initially asked about, it might be
more useful still to have a function where one could use a regular
expression as a chopping point instead of a substring.
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
[2014 date index]
[2014 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]