explode_implode

バージョン 1.0.0.0 (2.29 KB) 作成者: Sara Silva
Two functions: split string into pieces, join strings with delimiter in between.
ダウンロード: 3.8K
更新 2005/3/11

ライセンスの表示

%EXPLODE Splits string into pieces.
% EXPLODE(STRING,DELIMITERS) returns a cell array with the pieces
% of STRING found between any of the characters in DELIMITERS.
%
% [SPLIT,NUMPIECES] = EXPLODE(STRING,DELIMITERS) also returns the
% number of pieces found in STRING.
%
% Input arguments:
% STRING - the string to split (string)
% DELIMITERS - the delimiter characters (string)
% Output arguments:
% SPLIT - the split string (cell array), each cell is a piece
% NUMPIECES - the number of pieces found (integer)
%
% Example:
% STRING = 'ab_c,d,e fgh'
% DELIMITERS = '_,'
% [SPLIT,NUMPIECES] = EXPLODE(STRING,DELIMITERS)
% SPLIT = 'ab' 'c' 'd' 'e fgh'
% NUMPIECES = 4
%
% See also IMPLODE, STRTOK
%
% Created: Sara Silva (sara@itqb.unl.pt) - 2002.04.30

%IMPLODE Joins strings with delimiter in between.
% IMPLODE(PIECES,DELIMITER) returns a string containing all the
% strings in PIECES joined with the DELIMITER string in between.
%
% Input arguments:
% PIECES - the pieces of string to join (cell array), each cell is a piece
% DELIMITER - the delimiter string to put between the pieces (string)
% Output arguments:
% STRING - all the pieces joined with the delimiter in between (string)
%
% Example:
% PIECES = {'ab','c','d','e fgh'}
% DELIMITER = '->'
% STRING = IMPLODE(PIECES,DELIMITER)
% STRING = ab->c->d->e fgh
%
% See also EXPLODE, STRCAT
%
% Created: Sara Silva (sara@itqb.unl.pt) - 2002.08.25
% Modified: Sara Silva (sara@dei.uc.pt) - 2005.03.11
% - implode did not work if the delimiter was whitespace, so
% line 36 was replaced by line 37.
% - thank you to Matthew Davidson for pointing this out
% (and providing the solution!)

引用

Sara Silva (2024). explode_implode (https://www.mathworks.com/matlabcentral/fileexchange/3028-explode_implode), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R10
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCharacters and Strings についてさらに検索
謝辞

ヒントを与えたファイル: rsplit

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0

implode did not work if the delimiter was whitespace, so line 36 was replaced by line 37. explode remains the same.

Thank you to Matthew Davidson for pointing this out (and providing the solution!)