필터 지우기
필터 지우기

How to delete partial sub-string

조회 수: 1 (최근 30일)
Mekala balaji
Mekala balaji 2018년 4월 18일
댓글: Mekala balaji 2018년 4월 18일
Hi,
I have below cell array,
input:
{'JAK2';'JAKKVAR2KL';'JAKAKR8DW';'JAKK4';'JAK19';'JAKNUI87YU';'JAK0'}
I want to remove JAK,
My desired output:
{'2';'KVAR2KL';'AKR8DW';'K4';'19';NUI87YU';'0'}
I used strtok but I am not getting desired output,
data={'JAK2';'JAKKVAR2KL';'JAKAKR8DW';'JAKK4';'JAK19';'JAKNUI87YU';'JAK0'}
data =
7×1 cell array
'JAK2'
'JAKKVAR2KL'
'JAKAKR8DW'
'JAKK4'
'JAK19'
'JAKNUI87YU'
'JAK0'
>> a=strtok(data,'JAK')
a =
7×1 cell array
'2'
'V'
'R8DW'
'4'
'19'
'NUI87YU'
'0'

채택된 답변

Jan
Jan 2018년 4월 18일
편집: Jan 2018년 4월 18일
C = {'JAK2';'JAKKVAR2KL';'JAKAKR8DW';'JAKK4';'JAK19';'JAKNUI87YU';'JAK0'};
D = strrep(C, 'JAK', '')

strtok splits the string, when the key occurs. But you want to delete the key. Then strrep with an empty string works.

  댓글 수: 1
Mekala balaji
Mekala balaji 2018년 4월 18일
Sir,
if my original input is:
{'2';'KVAR2KL';'AKR8DW';'K4';'19';NUI87YU';'0'}
and I want to combine each cell (row) with JAK (JAK should attach to left side of each cell row), how to get desired output as below:
{'JAK2';'JAKKVAR2KL';'JAKAKR8DW';'JAKK4';'JAK19';'JAKNUI87YU';'JAK0'}

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by