How to use regexp to filter the following file names?
1 view (last 30 days)
Show older comments
Devarshi Patel
on 10 Jun 2019
Commented: Devarshi Patel
on 11 Jun 2019
Hello, lets assume that I have the following file format for my files,
fig_figure_mat2007_03_04_yield_2007_03_05
fig_figure_mat2008_03_07_yield_2008_03_08
fig_figure_mat2007_03_05_yield_2007_03_06
fig_figure_mat2008_04_05_yield_2008_04_06
How can I use regexp in this to sort the files out just by using the first bit of the date such as files are sorted in following order:
2007_03_04
2007_03_05
2008_03_07
2008_04_05
0 Comments
Accepted Answer
convert_to_metric
on 10 Jun 2019
Hi Devarshi,
Since your filenames have a predictable structure of consistent length, you could use hard coded indexing to extract that date and avoid regexp altogether. If filename is a character array containing fig_figure_mat2007_03_04_yield_2007_03_05, filename(15:24) should return the section you're looking for.
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!