Hi i have a string s='21-x1 4000. 4000. 0.'and i would like to replace the first 4000 without replacing the second 4000, i did use
strrep(s,'4000','1512.45')
but the outcome was ns = '21-x1 1512.45 1512.45 0.'
thanks,

 채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 26일

1 개 추천

s='21-x1 4000. 4000. 0.';
regexprep(s, '4000', '1512.45', 'once')

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by