How to find text structure within string array?

1 次查看(过去 30 天)
Hello,
please see below an example of file names I have:
"moose_0_-1_6_Coordinates-8580_138864_ 30-01-21_17-48-22_0.xml"
I've made in bold the required text (which is the date of file creation).
File names can vary a little a bit, but the bold structure would always exist.
Can I search somehow for a specific template/structure within my string?
Something like: ##-##-##_##-##-## (when # <--> digit).
Thank You !

采纳的回答

Stephen23
Stephen23 2022-8-15
编辑:Stephen23 2022-8-15
str = "moose_0_-1_6_Coordinates-8580_138864_ 30-01-21_17-48-22_0.xml";
rgx = '\d+-\d+-\d+_\d+-\d+-\d+';
out = regexp(str,rgx,'match','once')
out = "30-01-21_17-48-22"

更多回答(1 个)

Image Analyst
Image Analyst 2022-8-15

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by