How to find text structure within string array?

조회 수: 1 (최근 30일)
Mark Golberg
Mark Golberg 2022년 8월 15일
댓글: Mark Golberg 2022년 8월 15일
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