Prefix match in MATLAB -


hey guys, have simple problem in matlab:

i have strings this:

pic001 pic002 pic003 004 

not every string starts prefix "pic". how can cut off part "pic" numbers @ end shall remain have equal format strings?

greets, poeschlorn

if 'pic' ever occurs prefix in strings , else within strings use strrep remove this:

 >> x = {'pic001'; 'pic002'; 'pic003'; '004'}  x =       'pic001'     'pic002'     'pic003'     '004'  >> x = strrep(x, 'pic', '')  x =       '001'     '002'     '003'     '004' 

if 'pic' can occur elsewhere in strings , want remove when occurs prefix use strncmp compare first 3 characters of strings:

 >> x = {'pic001'; 'pic002'; 'pic003'; '004'}  x =       'pic001'     'pic002'     'pic003'     '004'  >> ii = find(strncmp(x, 'pic', 3))' x{ii}(1:3) = []; end >> x  x =       '001'     '002'     '003'     '004' 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -