Change name in files

2 ビュー (過去 30 日間)
DavidL88
DavidL88 2021 年 6 月 3 日
コメント済み: DavidL88 2021 年 6 月 3 日
I have a list of file names in a struct like this; 'Avg: 11_right | bl | _HLG_MOD (92 files) | _HGH'
How do I move '| _HGH' to before '(92 files)' so that I get; 'Avg: 11_right | bl | _HLG_MOD | _HGH (92 files)' for an entire list when the number of files is different for each entry?
I thought about using something like; strrep(OldComment, '(92 files) | _HGH', ' | _HGH (92 files) '); but the number of files changes across file names. Is there a way to amend this code to ignore the number of files?

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 3 日
S = 'Avg: 11_right | bl | _HLG_MOD (92 files) | _HGH'
S = 'Avg: 11_right | bl | _HLG_MOD (92 files) | _HGH'
T = regexprep(S, ' (\(.*\))\s*(.*)$', ' $2 $1')
T = 'Avg: 11_right | bl | _HLG_MOD | _HGH (92 files)'
Please check that the spacing is correct for your purposes
  1 件のコメント
DavidL88
DavidL88 2021 年 6 月 3 日
That worked perfectly, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by