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 CenterMATLAB Answers에서 Characters 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!)