How to use regexp to filter the following file names?

3 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

convert_to_metric
convert_to_metric am 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.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by