Insert underscore into the string
古いコメントを表示
a = datestr(now,31)
a = 2016-08-23 09:15:47
a = regexprep(a,'[^a-zA-Z0-9]','') = 20160823091547
a(1:2) = []
a = '160823091547'
Now i need to insert the underscore after the sixth element in the string
160823_091547
how can i do this?
is it possible to optimize the above steps or my approach is correct?
Thanks a lot
採用された回答
その他の回答 (2 件)
Azzi Abdelmalek
2016 年 8 月 23 日
a=[a(1:6) '_' a(7:end)]
Azzi Abdelmalek
2016 年 8 月 23 日
a = datestr(now,31)
a=datestr(a,'yymmdd_HHMMSS')
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!