strpat: a pedestrian, exactly matching pattern finder / replacer

버전 1.3.0.0 (2.83 KB) 작성자: us
STRPAT finds and replaces an exactly matching pattern in a character or numeric string
다운로드 수: 11.2K
업데이트 날짜: 2010/4/22

라이선스 보기

STRPAT searches for EXACTLY matching patterns
in a character or numeric string and replaces
the occurrences with another pattern.

a single or double precision pattern
may include NaNs

% examples

% - character strings

% note difference
% STRREP
strrep('aa_a_aaa_aa','a','XXX')
% XXXXXX_XXX_XXXXXXXXX_XXXXXX
%
% STRPAT
strpat('aa_a_aaa_aa','a','XXX')
% aa_XXX_aaa_aa

strpat('aa_a_aaa_aa','aa','X')
% X_a_aaa_X

% - numeric strings
strpat([1:3,pi,5:7],pi,nan)
% 1 2 3 NaN 5 6 7

strpat(pi*(1:6),pi*(4:5),[])
% 3.1416 6.2832 9.4248 18.85

strpat(pi*(1:6),pi*(4:5),[nan inf -inf nan])
% 3.1416 6.2832 9.4248 NaN Inf -Inf NaN 18.85

strpat(pi*(1:6),pi*(4:5),1:3)
% 3.1416 6.2832 9.4248 1 2 3 18.85

% - PATTERN including NaNs
strpat([-10,nan,1,-10,nan,nan,1,nan,1,-10],[nan,1],inf)
% -10 Inf -10 NaN Inf Inf -10

see also
>> help strpat
or the screenshot for help on this self-explanatory function

인용 양식

us (2024). strpat: a pedestrian, exactly matching pattern finder / replacer (https://www.mathworks.com/matlabcentral/fileexchange/1518-strpat-a-pedestrian-exactly-matching-pattern-finder-replacer), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R12.1
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.3.0.0

finally removed all pre-r12.1 legacy code for logical indexing; correction of a typo; version tag 22-Apr-2010 09:57:37

1.2.0.0

a pattern now may include NaNs; version tag 18-Apr-2010 02:33:59

1.0.0.0

changed engine for r14/r2006 versions, which runs much faster (no EVAL!). the old version has been added as STRPAT13. version tag 05-Jul-2006 16:12:19