Mercurial > octave-nkf
annotate scripts/strings/strsplit.m @ 19627:446c46af4b42 stable
strip trailing whitespace from most source files
* Makefile.am, NEWS, build-aux/common.mk, configure.ac,
doc/Makefile.am, doc/doxyhtml/Makefile.am,
doc/interpreter/Makefile.am, doc/interpreter/arith.txi,
doc/interpreter/audio.txi, doc/interpreter/basics.txi,
doc/interpreter/bugs.txi, doc/interpreter/container.txi,
doc/interpreter/cp-idx.txi, doc/interpreter/data.txi,
doc/interpreter/debug.txi, doc/interpreter/diagperm.txi,
doc/interpreter/diffeq.txi, doc/interpreter/doccheck/README,
doc/interpreter/doccheck/spellcheck, doc/interpreter/emacs.txi,
doc/interpreter/errors.txi, doc/interpreter/eval.txi,
doc/interpreter/expr.txi, doc/interpreter/external.txi,
doc/interpreter/fn-idx.txi, doc/interpreter/func.txi,
doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m,
doc/interpreter/gpl.txi, doc/interpreter/grammar.txi,
doc/interpreter/gui.txi, doc/interpreter/image.txi,
doc/interpreter/install.txi, doc/interpreter/interp.txi,
doc/interpreter/interpimages.m, doc/interpreter/intro.txi,
doc/interpreter/io.txi, doc/interpreter/java.txi,
doc/interpreter/linalg.txi, doc/interpreter/macros.texi,
doc/interpreter/matrix.txi, doc/interpreter/munge-texi.pl,
doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi,
doc/interpreter/obsolete.txi, doc/interpreter/octave-config.1,
doc/interpreter/octave.texi, doc/interpreter/oop.txi,
doc/interpreter/op-idx.txi, doc/interpreter/optim.txi,
doc/interpreter/package.txi, doc/interpreter/plot.txi,
doc/interpreter/poly.txi, doc/interpreter/preface.txi,
doc/interpreter/quad.txi, doc/interpreter/set.txi,
doc/interpreter/signal.txi, doc/interpreter/sparse.txi,
doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m,
doc/interpreter/stats.txi, doc/interpreter/stmt.txi,
doc/interpreter/strings.txi, doc/interpreter/system.txi,
doc/interpreter/testfun.txi, doc/interpreter/tips.txi,
doc/interpreter/var.txi, doc/interpreter/vectorize.txi,
doc/liboctave/Makefile.am, doc/liboctave/array.texi,
doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi,
doc/liboctave/dae.texi, doc/liboctave/diffeq.texi,
doc/liboctave/error.texi, doc/liboctave/factor.texi,
doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi,
doc/liboctave/install.texi, doc/liboctave/intro.texi,
doc/liboctave/liboctave.texi, doc/liboctave/matvec.texi,
doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi,
doc/liboctave/ode.texi, doc/liboctave/optim.texi,
doc/liboctave/preface.texi, doc/liboctave/quad.texi,
doc/liboctave/range.texi, doc/refcard/Makefile.am,
doc/refcard/refcard.tex, etc/HACKING, etc/NEWS.1, etc/NEWS.2,
etc/NEWS.3, etc/OLD-ChangeLogs/ChangeLog,
etc/OLD-ChangeLogs/doc-ChangeLog,
etc/OLD-ChangeLogs/scripts-ChangeLog,
etc/OLD-ChangeLogs/src-ChangeLog, etc/OLD-ChangeLogs/test-ChangeLog,
etc/PROJECTS, etc/README.Cygwin, etc/README.MacOS, etc/README.MinGW,
etc/README.gnuplot, etc/gdbinit, etc/icons/Makefile.am,
examples/@polynomial/end.m, examples/@polynomial/subsasgn.m,
examples/Makefile.am, examples/standalonebuiltin.cc,
libgui/Makefile.am, libgui/qterminal/libqterminal/README,
libgui/qterminal/libqterminal/unix/BlockArray.cpp,
libgui/qterminal/libqterminal/unix/BlockArray.h,
libgui/qterminal/libqterminal/unix/Character.h,
libgui/qterminal/libqterminal/unix/CharacterColor.h,
libgui/qterminal/libqterminal/unix/Emulation.cpp,
libgui/qterminal/libqterminal/unix/Emulation.h,
libgui/qterminal/libqterminal/unix/Filter.cpp,
libgui/qterminal/libqterminal/unix/Filter.h,
libgui/qterminal/libqterminal/unix/History.cpp,
libgui/qterminal/libqterminal/unix/History.h,
libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp,
libgui/qterminal/libqterminal/unix/KeyboardTranslator.h,
libgui/qterminal/libqterminal/unix/LineFont.h,
libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp,
libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h,
libgui/qterminal/libqterminal/unix/Screen.cpp,
libgui/qterminal/libqterminal/unix/Screen.h,
libgui/qterminal/libqterminal/unix/ScreenWindow.cpp,
libgui/qterminal/libqterminal/unix/ScreenWindow.h,
libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp,
libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h,
libgui/qterminal/libqterminal/unix/Vt102Emulation.h,
libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp,
libgui/qterminal/qterminal/main.cpp,
libgui/src/m-editor/file-editor-tab.cc, libgui/src/octave-gui.cc,
libgui/src/octave-qt-link.cc, libinterp/corefcn/data.cc,
libinterp/corefcn/defun-int.h, libinterp/corefcn/det.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc,
libinterp/corefcn/graphics.in.h, libinterp/corefcn/ls-mat5.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/oct-tex-parser.yy,
libinterp/corefcn/oct-tex-symbols.in, libinterp/corefcn/quadcc.cc,
libinterp/corefcn/zfstream.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__voronoi__.cc, libinterp/gendoc.pl,
libinterp/genprops.awk, libinterp/mk-errno-list, libinterp/mk-pkg-add,
libinterp/mkbuiltins, libinterp/mkdefs, libinterp/mkdocs,
libinterp/mkops, libinterp/octave-value/ov-java.cc,
libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/octave.gperf, liboctave/Makefile.am,
liboctave/array/Array.cc, liboctave/array/module.mk,
liboctave/cruft/daspk/datv.f, liboctave/cruft/daspk/dcnst0.f,
liboctave/cruft/daspk/dcnstr.f, liboctave/cruft/daspk/ddasic.f,
liboctave/cruft/daspk/ddasid.f, liboctave/cruft/daspk/ddasik.f,
liboctave/cruft/daspk/ddaspk.f, liboctave/cruft/daspk/ddstp.f,
liboctave/cruft/daspk/ddwnrm.f, liboctave/cruft/daspk/dfnrmd.f,
liboctave/cruft/daspk/dfnrmk.f, liboctave/cruft/daspk/dhels.f,
liboctave/cruft/daspk/dheqr.f, liboctave/cruft/daspk/dinvwt.f,
liboctave/cruft/daspk/dlinsd.f, liboctave/cruft/daspk/dlinsk.f,
liboctave/cruft/daspk/dmatd.f, liboctave/cruft/daspk/dnedd.f,
liboctave/cruft/daspk/dnedk.f, liboctave/cruft/daspk/dnsd.f,
liboctave/cruft/daspk/dnsid.f, liboctave/cruft/daspk/dnsik.f,
liboctave/cruft/daspk/dnsk.f, liboctave/cruft/daspk/dorth.f,
liboctave/cruft/daspk/dslvd.f, liboctave/cruft/daspk/dslvk.f,
liboctave/cruft/daspk/dspigm.f, liboctave/cruft/daspk/dyypnw.f,
liboctave/cruft/dasrt/ddasrt.f, liboctave/cruft/dasrt/drchek.f,
liboctave/cruft/dassl/ddaslv.f, liboctave/cruft/dassl/ddassl.f,
liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/module.mk,
liboctave/cruft/odepack/cfode.f, liboctave/cruft/odepack/dlsode.f,
liboctave/cruft/odepack/ewset.f, liboctave/cruft/odepack/intdy.f,
liboctave/cruft/odepack/prepj.f, liboctave/cruft/odepack/sintdy.f,
liboctave/cruft/odepack/slsode.f, liboctave/cruft/odepack/solsy.f,
liboctave/cruft/odepack/ssolsy.f, liboctave/cruft/odepack/stode.f,
liboctave/cruft/odepack/vnorm.f, liboctave/cruft/ranlib/Basegen.doc,
liboctave/cruft/ranlib/README, liboctave/cruft/ranlib/genbet.f,
liboctave/cruft/ranlib/genexp.f, liboctave/cruft/ranlib/gennch.f,
liboctave/cruft/ranlib/gennf.f, liboctave/cruft/ranlib/gennor.f,
liboctave/cruft/ranlib/getsd.f, liboctave/cruft/ranlib/initgn.f,
liboctave/cruft/ranlib/phrtsd.f, liboctave/cruft/ranlib/randlib.fdoc,
liboctave/cruft/ranlib/setsd.f, liboctave/cruft/ranlib/tstgmn.for,
liboctave/cruft/ranlib/tstmid.for, liboctave/cruft/slatec-fn/atanh.f,
liboctave/cruft/slatec-fn/datanh.f,
liboctave/cruft/slatec-fn/xgmainc.f,
liboctave/cruft/slatec-fn/xsgmainc.f, liboctave/numeric/module.mk,
liboctave/operators/mk-ops.awk, liboctave/operators/mx-ops,
liboctave/operators/sparse-mk-ops.awk,
liboctave/operators/sparse-mx-ops, liboctave/operators/vx-ops,
liboctave/util/module.mk, run-octave.in, scripts/@ftp/ftp.m,
scripts/audio/wavread.m, scripts/deprecated/java_convert_matrix.m,
scripts/deprecated/java_debug.m, scripts/deprecated/java_invoke.m,
scripts/deprecated/java_new.m,
scripts/deprecated/java_unsigned_conversion.m,
scripts/deprecated/javafields.m, scripts/deprecated/javamethods.m,
scripts/deprecated/shell_cmd.m, scripts/general/accumarray.m,
scripts/general/display.m, scripts/general/fieldnames.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/isa.m,
scripts/general/methods.m, scripts/general/sortrows.m,
scripts/geometry/convhull.m, scripts/geometry/delaunay.m,
scripts/geometry/delaunay3.m, scripts/geometry/delaunayn.m,
scripts/geometry/griddata.m, scripts/geometry/griddatan.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/gui/guihandles.m, scripts/gui/inputdlg.m,
scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m,
scripts/gui/uigetfile.m, scripts/gui/waitbar.m, scripts/gui/warndlg.m,
scripts/help/doc.m, scripts/help/help.m, scripts/help/type.m,
scripts/image/bone.m, scripts/image/cmpermute.m,
scripts/image/cmunique.m, scripts/image/colorcube.m,
scripts/image/colormap.m, scripts/image/contrast.m,
scripts/image/gray2ind.m, scripts/image/image.m,
scripts/image/imshow.m, scripts/image/ind2gray.m, scripts/image/jet.m,
scripts/image/rgb2ntsc.m, scripts/image/spinmap.m,
scripts/io/importdata.m, scripts/io/strread.m, scripts/io/textread.m,
scripts/io/textscan.m, scripts/java/java_get.m,
scripts/java/java_set.m, scripts/java/javaaddpath.m,
scripts/java/javaclasspath.m, scripts/java/javamem.m,
scripts/linear-algebra/linsolve.m, scripts/linear-algebra/qzhess.m,
scripts/miscellaneous/debug.m, scripts/miscellaneous/desktop.m,
scripts/miscellaneous/dir.m, scripts/miscellaneous/dos.m,
scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m,
scripts/miscellaneous/getappdata.m, scripts/miscellaneous/inputname.m,
scripts/miscellaneous/license.m, scripts/miscellaneous/ls_command.m,
scripts/miscellaneous/run.m, scripts/miscellaneous/setfield.m,
scripts/miscellaneous/unix.m, scripts/miscellaneous/ver.m,
scripts/mk-pkg-add, scripts/mkdoc.pl,
scripts/optimization/fminsearch.m, scripts/optimization/optimset.m,
scripts/optimization/sqp.m, scripts/pkg/pkg.m,
scripts/pkg/private/create_pkgadddel.m,
scripts/pkg/private/fix_depends.m, scripts/pkg/private/install.m,
scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m,
scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m,
scripts/plot/appearance/datetick.m, scripts/plot/appearance/grid.m,
scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m,
scripts/plot/appearance/shading.m, scripts/plot/appearance/text.m,
scripts/plot/appearance/title.m, scripts/plot/appearance/xlabel.m,
scripts/plot/appearance/ylabel.m, scripts/plot/appearance/zlabel.m,
scripts/plot/draw/area.m, scripts/plot/draw/bar.m,
scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m,
scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m,
scripts/plot/draw/contourf.m, scripts/plot/draw/ellipsoid.m,
scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m,
scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m,
scripts/plot/draw/ezpolar.m, scripts/plot/draw/fill.m,
scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m,
scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m,
scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m,
scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m,
scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m,
scripts/plot/draw/plotyy.m, scripts/plot/draw/private/__bar__.m,
scripts/plot/draw/private/__contour__.m,
scripts/plot/draw/private/__errplot__.m,
scripts/plot/draw/private/__ezplot__.m,
scripts/plot/draw/private/__patch__.m,
scripts/plot/draw/private/__stem__.m, scripts/plot/draw/rectangle.m,
scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m,
scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m,
scripts/plot/draw/semilogx.m, scripts/plot/draw/shrinkfaces.m,
scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m,
scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m,
scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m,
scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m,
scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m,
scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m,
scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m,
scripts/plot/util/__gnuplot_drawnow__.m,
scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/axes.m,
scripts/plot/util/clf.m, scripts/plot/util/copyobj.m,
scripts/plot/util/figure.m, scripts/plot/util/gcbo.m,
scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hggroup.m,
scripts/plot/util/meshgrid.m, scripts/plot/util/newplot.m,
scripts/plot/util/print.m,
scripts/plot/util/private/__add_default_menu__.m,
scripts/plot/util/private/__fltk_print__.m,
scripts/plot/util/private/__gnuplot_print__.m,
scripts/plot/util/private/__print_parse_opts__.m,
scripts/plot/util/refreshdata.m, scripts/plot/util/subplot.m,
scripts/polynomial/conv.m, scripts/polynomial/poly.m,
scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m,
scripts/polynomial/polyval.m,
scripts/polynomial/private/__splinefit__.m,
scripts/polynomial/spline.m, scripts/prefs/prefdir.m,
scripts/prefs/preferences.m, scripts/prefs/private/prefsfile.m,
scripts/prefs/rmpref.m, scripts/signal/freqz.m,
scripts/signal/module.mk, scripts/sparse/eigs.m, scripts/sparse/pcg.m,
scripts/sparse/private/__sprand_impl__.m, scripts/sparse/sprand.m,
scripts/sparse/sprandn.m, scripts/sparse/spy.m, scripts/sparse/svds.m,
scripts/specfun/expint.m, scripts/specfun/factor.m,
scripts/special-matrix/gallery.m, scripts/special-matrix/hankel.m,
scripts/special-matrix/toeplitz.m, scripts/startup/inputrc,
scripts/statistics/base/kurtosis.m, scripts/statistics/base/moment.m,
scripts/statistics/base/qqplot.m, scripts/statistics/base/var.m,
scripts/statistics/distributions/betarnd.m,
scripts/statistics/distributions/binoinv.m,
scripts/statistics/distributions/binopdf.m,
scripts/statistics/distributions/binornd.m,
scripts/statistics/distributions/cauchy_rnd.m,
scripts/statistics/distributions/chi2rnd.m,
scripts/statistics/distributions/discrete_pdf.m,
scripts/statistics/distributions/discrete_rnd.m,
scripts/statistics/distributions/empirical_rnd.m,
scripts/statistics/distributions/exprnd.m,
scripts/statistics/distributions/frnd.m,
scripts/statistics/distributions/gamrnd.m,
scripts/statistics/distributions/geornd.m,
scripts/statistics/distributions/hygernd.m,
scripts/statistics/distributions/kolmogorov_smirnov_cdf.m,
scripts/statistics/distributions/laplace_cdf.m,
scripts/statistics/distributions/laplace_pdf.m,
scripts/statistics/distributions/logistic_cdf.m,
scripts/statistics/distributions/logistic_pdf.m,
scripts/statistics/distributions/lognrnd.m,
scripts/statistics/distributions/nbincdf.m,
scripts/statistics/distributions/nbininv.m,
scripts/statistics/distributions/nbinpdf.m,
scripts/statistics/distributions/nbinrnd.m,
scripts/statistics/distributions/normrnd.m,
scripts/statistics/distributions/poissinv.m,
scripts/statistics/distributions/poissrnd.m,
scripts/statistics/distributions/tinv.m,
scripts/statistics/distributions/trnd.m,
scripts/statistics/distributions/unidcdf.m,
scripts/statistics/distributions/unidpdf.m,
scripts/statistics/distributions/unidrnd.m,
scripts/statistics/distributions/unifrnd.m,
scripts/statistics/distributions/wblrnd.m,
scripts/statistics/models/module.mk,
scripts/statistics/tests/kruskal_wallis_test.m,
scripts/strings/base2dec.m, scripts/strings/deblank.m,
scripts/strings/dec2base.m, scripts/strings/dec2bin.m,
scripts/strings/dec2hex.m, scripts/strings/mat2str.m,
scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m,
scripts/strings/str2num.m, scripts/strings/strcat.m,
scripts/strings/strjoin.m, scripts/strings/strsplit.m,
scripts/strings/strtok.m, scripts/strings/strtrim.m,
scripts/strings/strtrunc.m, scripts/strings/substr.m,
scripts/testfun/__run_test_suite__.m, scripts/testfun/speed.m,
scripts/testfun/test.m, scripts/time/asctime.m,
scripts/time/datenum.m, scripts/time/datevec.m,
scripts/time/weekday.m, src/Makefile.am, test/Makefile.am,
test/build-bc-overload-tests.sh, test/build-sparse-tests.sh,
test/jit.tst, test/line-continue.tst: Strip trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 08:26:57 -0500 |
parents | 1874a5a142ee |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17405
diff
changeset
|
1 ## Copyright (C) 2009-2013 Jaroslav Hajek |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 ## |
11104 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 ## |
11104 | 10 ## Octave is distributed in the hope that it will be useful, but |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 ## |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
11104 | 16 ## along with Octave; see the file COPYING. If not, see |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{cstr}] =} strsplit (@var{s}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
21 ## @deftypefnx {Function File} {[@var{cstr}] =} strsplit (@var{s}, @var{del}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
22 ## @deftypefnx {Function File} {[@var{cstr}] =} strsplit (@dots{}, @var{name}, @var{value}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
23 ## @deftypefnx {Function File} {[@var{cstr}, @var{matches}] =} strsplit (@dots{}) |
16411
5be43435bd5b
Improve speed and backward compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
24 ## Split the string @var{s} using the delimiters specified by @var{del} |
18185
1874a5a142ee
doc: Fix documentation for strsplit (bug #41062).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
25 ## and return a cell string array of substrings. If a delimiter is not |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
26 ## specified the string, @var{s}, is split at whitespace. The delimiter, |
18185
1874a5a142ee
doc: Fix documentation for strsplit (bug #41062).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
27 ## @var{del} may be a string, a scalar cell string, or cell string array. |
1874a5a142ee
doc: Fix documentation for strsplit (bug #41062).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
28 ## By default, consecutive delimiters in the input string @var{s} are |
1874a5a142ee
doc: Fix documentation for strsplit (bug #41062).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
29 ## collapsed into one. |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
30 ## |
18185
1874a5a142ee
doc: Fix documentation for strsplit (bug #41062).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
31 ## The second output, @var{matches}, returns the delimiters which were matched |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
32 ## in the original string. |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
33 ## |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
34 ## Example: |
13929
9cae456085c2
Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13776
diff
changeset
|
35 ## |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
36 ## @example |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
37 ## strsplit ("a b c") |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
38 ## @result{} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
39 ## @{ |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
40 ## [1,1] = a |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
41 ## [1,2] = b |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
42 ## [1,3] = c |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
43 ## @} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
44 ## |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
45 ## strsplit ("a,b,c", ",") |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
46 ## @result{} |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
47 ## @{ |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
48 ## [1,1] = a |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
49 ## [1,2] = b |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
50 ## [1,3] = c |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
51 ## @} |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
52 ## |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
53 ## strsplit ("a foo b,bar c", @{"\s", "foo", "bar"@}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
54 ## @result{} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
55 ## @{ |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
56 ## [1,1] = a |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
57 ## [1,2] = b |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
58 ## [1,3] = c |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
59 ## @} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
60 ## |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
61 ## strsplit ("a,,b, c", @{",", " "@}, false) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
62 ## @result{} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
63 ## @{ |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
64 ## [1,1] = a |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
65 ## [1,2] = |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
66 ## [1,3] = b |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
67 ## [1,4] = |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
68 ## [1,5] = c |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
69 ## @} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
70 ## |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
71 ## @end example |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
72 ## |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
73 ## Supported @var{name}/@var{value} pair arguments are; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
74 ## |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
75 ## @itemize |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
76 ## @item @var{collapsedelimiters} may take the value of @var{true} or |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
77 ## @var{false} with the default being @var{false}. |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
78 ## |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
79 ## @item @var{delimitertype} may take the value of @code{simple} or |
16816
12005245b645
doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
80 ## @code{regularexpression}. The default is @var{delimitertype} is |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
81 ## @code{simple}. |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
82 ## @end itemize |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
83 ## |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
84 ## Example: |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
85 ## |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
86 ## @example |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
87 ## strsplit ("a foo b,bar c", ",|\\s|foo|bar", "delimitertype", "regularexpression") |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
88 ## @result{} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
89 ## @{ |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
90 ## [1,1] = a |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
91 ## [1,2] = b |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
92 ## [1,3] = c |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
93 ## @} |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
94 ## |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
95 ## strsplit ("a,,b, c", "[, ]", false, "delimitertype", "regularexpression") |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
96 ## @result{} |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
97 ## @{ |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
98 ## [1,1] = a |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
99 ## [1,2] = |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
100 ## [1,3] = b |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
101 ## [1,4] = |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
102 ## [1,5] = c |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
103 ## @} |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
104 ## |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
105 ## strsplit ("a,\t,b, c", @{',', '\s'@}, "delimitertype", "regularexpression") |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
106 ## @result{} |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
107 ## @{ |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
108 ## [1,1] = a |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
109 ## [1,2] = b |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
110 ## [1,3] = c |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
111 ## @} |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
112 ## |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
113 ## strsplit ("a,\t,b, c", @{',', ' ', '\t'@}, "collapsedelimiters", false) |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
114 ## @result{} |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
115 ## @{ |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
116 ## [1,1] = a |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
117 ## [1,2] = |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
118 ## [1,3] = |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
119 ## [1,4] = b |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
120 ## [1,5] = |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
121 ## [1,6] = c |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
122 ## @} |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
123 ## @end example |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18185
diff
changeset
|
124 ## |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
125 ## @seealso{ostrsplit, strjoin, strtok, regexp} |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
126 ## @end deftypefn |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
127 |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
128 function [result, matches] = strsplit (str, del, varargin) |
8884 | 129 |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
130 args.collapsedelimiters = true; |
16411
5be43435bd5b
Improve speed and backward compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
131 args.delimitertype = "default"; |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
132 |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
133 [reg, params] = parseparams (varargin); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
134 |
16712
9ce08a1efc29
fix strsplit input validation
Mike Miller <mtmiller@ieee.org>
parents:
16557
diff
changeset
|
135 if (nargin < 1) |
9ce08a1efc29
fix strsplit input validation
Mike Miller <mtmiller@ieee.org>
parents:
16557
diff
changeset
|
136 print_usage (); |
9ce08a1efc29
fix strsplit input validation
Mike Miller <mtmiller@ieee.org>
parents:
16557
diff
changeset
|
137 elseif (numel (reg) > 1) |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
138 print_usage (); |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
139 elseif (numel (reg) == 1) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
140 if (islogical (reg{1}) || isnumeric (reg{1})) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
141 args.collapsedelimiters = reg{1}; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
142 else |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
143 print_usage (); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
144 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
145 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
146 fields = fieldnames (args); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
147 for n = 1:2:numel(params) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
148 if (any (strcmpi (params{n}, fields))) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
149 args.(lower(params{n})) = params{n+1}; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
150 elseif (ischar (varargin{n})) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
151 error ("strsplit:invalid_parameter_name", |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16727
diff
changeset
|
152 "strsplit: invalid parameter name, '%s'", varargin{n}); |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
153 else |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
154 print_usage (); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
155 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
156 endfor |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
157 |
16411
5be43435bd5b
Improve speed and backward compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
158 if (strcmpi (args.delimitertype, "default")) |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
159 args.delimitertype = "simple"; |
16411
5be43435bd5b
Improve speed and backward compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
160 endif |
5be43435bd5b
Improve speed and backward compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
161 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
162 ## Save the length of the "delimitertype" parameter |
17405
3f0ed69d21c6
Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents:
17386
diff
changeset
|
163 length_deltype = length (args.delimitertype); |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
164 |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
165 if (nargin == 1 || (nargin > 1 && (islogical (del) || isnumeric (del)))) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
166 if (nargin > 1) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
167 ## Second input is the "collapsedelimiters" parameter |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
168 args.collapsedelimiters = del; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
169 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
170 ## Set proper default for the delimiter type |
17405
3f0ed69d21c6
Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents:
17386
diff
changeset
|
171 if (strncmpi (args.delimitertype, "simple", length (args.delimitertype))) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
172 del = {" ","\f","\n","\r","\t","\v"}; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
173 else |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
174 del = "\\s"; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
175 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
176 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
177 |
16712
9ce08a1efc29
fix strsplit input validation
Mike Miller <mtmiller@ieee.org>
parents:
16557
diff
changeset
|
178 if (! ischar (str) || (! ischar (del) && ! iscellstr (del))) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
179 error ("strsplit: S and DEL must be string values"); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
180 elseif (! isscalar (args.collapsedelimiters)) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
181 error ("strsplit: COLLAPSEDELIMITERS must be a scalar value"); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
182 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
183 |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
184 if (strncmpi (args.delimitertype, "simple", length_deltype)) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
185 if (iscellstr (del)) |
16557
d50bca1cdc22
Support escaped characters in sq_strings for strsplit.m.
Ben Abbott <bpabbott@mac.com>
parents:
16554
diff
changeset
|
186 del = cellfun (@do_string_escapes, del, "uniformoutput", false); |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
187 else |
16557
d50bca1cdc22
Support escaped characters in sq_strings for strsplit.m.
Ben Abbott <bpabbott@mac.com>
parents:
16554
diff
changeset
|
188 del = do_string_escapes (del); |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
189 endif |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
190 ## This is clumsy, but needed for multi-row strings |
16557
d50bca1cdc22
Support escaped characters in sq_strings for strsplit.m.
Ben Abbott <bpabbott@mac.com>
parents:
16554
diff
changeset
|
191 del = regexprep (del, '([^\w])', '\\$1'); |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
192 endif |
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
193 |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
194 if (isempty (str)) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
195 result = {str}; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
196 elseif (strncmpi (args.delimitertype, "regularexpression", length_deltype) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
197 || strncmpi (args.delimitertype, "simple", length_deltype)) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
198 if (iscellstr (del)) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
199 del = sprintf ('%s|', del{:}); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
200 del(end) = []; |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
201 endif |
16554
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
202 if (args.collapsedelimiters) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
203 del = ["(", del, ")+"]; |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
204 endif |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
205 [result, ~, ~, ~, matches] = regexp (str, del, "split"); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
206 else |
16766
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16727
diff
changeset
|
207 error ("strsplit:invalid_delimitertype", |
7268845c0a1e
avoid backquote in error messages, some uses in doc strings
John W. Eaton <jwe@octave.org>
parents:
16727
diff
changeset
|
208 "strsplit: Invalid DELIMITERTYPE"); |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
209 endif |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
210 endfunction |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
211 |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17336
diff
changeset
|
212 |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
213 %!shared str |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
214 %! str = "The rain in Spain stays mainly in the plain."; |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
215 % Split on all whitespace. |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
216 %!assert (strsplit (str), {"The", "rain", "in", "Spain", "stays", ... |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
217 %! "mainly", "in", "the", "plain."}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
218 % Split on "ain". |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
219 %!assert (strsplit (str, "ain"), {"The r", " in Sp", " stays m", ... |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
220 %! "ly in the pl", "."}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
221 % Split on " " and "ain" (treating multiple delimiters as one). |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
222 %!test |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
223 %! s = strsplit (str, '\s|ain', true, "delimitertype", "r"); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
224 %! assert (s, {"The", "r", "in", "Sp", "stays", "m", "ly", "in", "the", "pl", "."}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
225 %!test |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
226 %! s = strsplit (str, "\\s|ain", true, "delimitertype", "r"); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
227 %! assert (s, {"The", "r", "in", "Sp", "stays", "m", "ly", "in", "the", "pl", "."}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
228 %!test |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
229 %! [s, m] = strsplit (str, {"\\s", "ain"}, true, "delimitertype", "r"); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
230 %! assert (s, {"The", "r", "in", "Sp", "stays", "m", "ly", "in", "the", "pl", "."}) |
16554
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
231 %! assert (m, {" ", "ain ", " ", "ain ", " ", "ain", " ", " ", " ", "ain"}) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
232 % Split on " " and "ain", and treat multiple delimiters separately. |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
233 %!test |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
234 %! [s, m] = strsplit (str, {" ", "ain"}, "collapsedelimiters", false); |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
235 %! assert (s, {"The", "r", "", "in", "Sp", "", "stays", "m", "ly", "in", "the", "pl", "."}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
236 %! assert (m, {" ", "ain", " ", " ", "ain", " ", " ", "ain", " ", " ", " ", "ain"}) |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
237 |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
238 %!assert (strsplit ("road to hell"), {"road", "to", "hell"}) |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
239 %!assert (strsplit ("road to hell", " "), {"road", "to", "hell"}) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
240 %!assert (strsplit ("road to^hell", {" ","^"}), {"road", "to", "hell"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
241 %!assert (strsplit ("road to--hell", {" ","-"}, true), {"road", "to", "hell"}) |
16411
5be43435bd5b
Improve speed and backward compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
242 %!assert (strsplit (["a,bc,,de"], ",", false, "delimitertype", "s"), {"a", "bc", "", "de"}) |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
243 %!assert (strsplit (["a,bc,,de"], ",", false), {"a", "bc", "", "de"}) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
244 %!assert (strsplit (["a,bc,de"], ",", true), {"a", "bc", "de"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
245 %!assert (strsplit (["a,bc,de"], {","," "}, true), {"a", "bc", "de"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
246 |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
247 %!assert (strsplit ("road to hell", " ", "delimitertype", "r"), {"road", "to", "hell"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
248 %!assert (strsplit ("road to^hell", '\^| ', "delimitertype", "r"), {"road", "to", "hell"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
249 %!assert (strsplit ("road to^hell", "[ ^]", "delimitertype", "r"), {"road", "to", "hell"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
250 %!assert (strsplit ("road to--hell", "[ -]", false, "delimitertype", "r"), {"road", "", "", "to", "", "hell"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
251 %!assert (strsplit (["a,bc,de"], ",", "delimitertype", "r"), {"a", "bc", "de"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
252 %!assert (strsplit (["a,bc,,de"], ",", false, "delimitertype", "r"), {"a", "bc", "", "de"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
253 %!assert (strsplit (["a,bc,de"], ",", true, "delimitertype", "r"), {"a", "bc", "de"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
254 %!assert (strsplit (["a,bc,de"], "[, ]", true, "delimitertype", "r"), {"a", "bc", "de"}) |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
255 %!assert (strsplit ("hello \t world", 1, "delimitertype", "r"), {"hello", "world"}); |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
256 |
16557
d50bca1cdc22
Support escaped characters in sq_strings for strsplit.m.
Ben Abbott <bpabbott@mac.com>
parents:
16554
diff
changeset
|
257 %!assert (strsplit ("foo\tbar", '\t', "delimitertype", "r"), {"foo", "bar"}) |
d50bca1cdc22
Support escaped characters in sq_strings for strsplit.m.
Ben Abbott <bpabbott@mac.com>
parents:
16554
diff
changeset
|
258 %!assert (strsplit ("foo\tbar", '\t', "delimitertype", "s"), {"foo", "bar"}) |
d50bca1cdc22
Support escaped characters in sq_strings for strsplit.m.
Ben Abbott <bpabbott@mac.com>
parents:
16554
diff
changeset
|
259 |
16554
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
260 ## Test "match" for consecutive delmiters |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
261 %!test |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
262 %! [a, m] = strsplit ("a\t \nb", '\s', 'delimitertype', 'regularexpression', |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
263 %! 'collapsedelimiters', false); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
264 %! assert (a, {"a", "", "", "b"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
265 %! assert (m, {"\t", " ", "\n"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
266 %!test |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
267 %! [a, m] = strsplit ("a\t \nb", '\s', false, 'delimitertype', 'regularexpression'); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
268 %! assert (a, {"a", "", "", "b"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
269 %! assert (m, {"\t", " ", "\n"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
270 %!test |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
271 %! [a, m] = strsplit ("a\t \nb", '\s', "delimitertype", "regularexpression"); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
272 %! assert (a, {"a", "b"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
273 %! assert (m, {"\t \n"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
274 %!test |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
275 %! [a, m] = strsplit ("a\t \nb", {"\t", " ", "\n"}, "delimitertype", "simple"); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
276 %! assert (a, {"a", "b"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
277 %! assert (m, {"\t \n"}) |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
278 %!test |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
279 %! [s, m] = strsplit ("hello \t world", 1); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
280 %! assert (s, {"hello", "world"}); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
281 %! assert (m, {" \t "}); |
03a28487fa9d
Collect collapsed delimiters in strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16411
diff
changeset
|
282 |
16727
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
283 %% Compatibility |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
284 %! assert (strsplit ("", "a"), {""}) |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
285 %! assert (strsplit ("a", "a"), {"", ""}) |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
286 %! assert (strsplit ("aa", "a"), {"", ""}) |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
287 %! assert (strsplit ("aaa", "a"), {"", ""}) |
3ce3579405f8
Remove the "legacy" delimiter type from strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16712
diff
changeset
|
288 |
13701
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
289 %% Test input validation |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
290 %!error strsplit () |
46e68badedb8
strsplit.m: Expand to accept 2-D character arrays. Improve input validation.
Rik <octave@nomad.inbox5.com>
parents:
12915
diff
changeset
|
291 %!error strsplit ("abc", "b", true, 4) |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
292 %!error <S and DEL must be string values> strsplit (123, "b") |
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
15521
diff
changeset
|
293 %!error <COLLAPSEDELIMITERS must be a scalar value> strsplit ("abc", "def", ones (3,3)) |
8877
2c8b2399247b
implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
294 |