Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
selection files from part of his name
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have a list with the name of several files. I woudl like to selection all the files that contain a certain characters like 3pi2 or 5pi2
List.name
'Box_36_alfa=3pi2_super-arxiv-1023412_fx.txt'
'Box_37_alfa=3pi2_super-arxiv-5612352_fx.txt'
'Box_38_alfa=5pi2_super-arxiv-3567120_fx.txt'
'Box_38_alfa=5pi2_super-arxiv-856132_fx.txt'
i have tried use strfind(List.name,'3pi2?','match'), but does not work
0 Commenti
Risposte (1)
Guillaume
il 20 Feb 2020
Modificato: Guillaume
il 20 Feb 2020
Patterns for strfind and its recommended replacement contains don't support wildcard characters such as * and ?. In any case, there's no 'match' option for strfind. It looks like you mixed the syntax for regexp with the syntax for strfind.
regexp would indeed solve your problem. However, note that ? in a regular expression doesn't mean match any character. It means match the previous character 0 or 1 time. A valid regular expression for what you want:
~cellfun(@isempty, regexp(List.Name, '(3|5)pi2', 'once')
This will return a logical vector indicated which elements of List.Name match the pattern.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!