필터 지우기
필터 지우기

strrep with replacing precise word and no ' ' explicit in code

조회 수: 3 (최근 30일)
Dominique Joubert
Dominique Joubert 2018년 9월 19일
댓글: Walter Roberson 2018년 9월 19일
i have an array in a loop:
use{i,1}=strrep(use{i,1},statename{j,1},xx{1,j})
the idea is to find precise statenames and repacle them with xx
but its doing parts.
how do i use the lookbefoe and after idea here, with no ' 'in the code?
DJ

채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 19일
Do not use strrep for this: use regexprep with lookaround operators.
  댓글 수: 2
Dominique Joubert
Dominique Joubert 2018년 9월 19일
편집: Stephen23 2018년 9월 19일
use{i,1}=regexprep(use{i,1},['(?<=[^a-zA-Z,0-9])',statename{j},'(?=[^a-zA-Z,0-9])'],xx{1,j});
Walter Roberson
Walter Roberson 2018년 9월 19일
Are you sure comma to be part of the list? Those are literal comma not range separators.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by