필터 지우기
필터 지우기

adding charecters to a string

조회 수: 3 (최근 30일)
aya qassim
aya qassim 2018년 12월 25일
댓글: aya qassim 2018년 12월 25일
How can I add a charecter or an element into a string.
for exaple I have the word 'sTudent' I need to add the letter B after each letter in the word
wich means I should have a an aswer 'sBTBuBdBeBnBt'
a string is just a word without spaces.
it has to be added but not after the last letter in the word as it shown in the example.
please help me!

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 25일
T = regexprep('sTudent', '.', '$&B')
or
T = 'sTudent';
T(2,:) = 'B';
T = reshape(T, 1, []);
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 12월 25일
T = regexprep('sTudent', '.(?=.)', '$&B')
or
T = 'sTudent';
T(2,:) = 'B';
T = reshape(T, 1, []);
T(end) = [];
aya qassim
aya qassim 2018년 12월 25일
thank you very much:)

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

추가 답변 (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