adding charecters to a string

1 回表示 (過去 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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by