Filter a cell array with words

Hi,
assume you have the cell array{1,1} with a text called "XXXX-adsaads". I want the the portion -adsaads to be removed so that I only get XXXX. How can I do this?

2 件のコメント

Walter Roberson
Walter Roberson 2019 年 7 月 28 日
Is the "adsaads" known ahead of time? Or are you wanting to find the part before the first - ? or are you wanting to find the part before the last - in cases where there are multiple - ?
AA
AA 2019 年 7 月 28 日
the only thing that is known is that a four or three lettered wording comes before the "-" and after the "-" more words are coming. i want to FILTER out everything that comes after the "-".

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

 採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 28 日

1 投票

trimedcell = regexprep(YourCellArray, '-.*', '', 'once');

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

AA
2019 年 7 月 28 日

回答済み:

2019 年 7 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by