Find specific text within string ('contains' command?)

Hello,
I have a list of strings (1x45 string) and would like to identify the index of where a specific string is located.
My input will always be an exact match to one of the entries in my list, so the output should be a single number.
The contains command would work, except some entries in the list of strings are found multiple times.
For example the first entry in my list is "POWERUP". the seventh entry is "POWERUP_RUN6".
Given an input of "POWERUP", I need something that will identify index 1 and not indices 1 and 7.
Thanks,
Matt

 採用された回答

Guillaume
Guillaume 2020 年 1 月 13 日

0 投票

If you're looking for an exact match, then it's strcmp you want, not contains.
find(strcmp(list, searchinput))

1 件のコメント

Matthew
Matthew 2020 年 1 月 13 日
Thanks Guillaume! I knew it'd be simple but wasn't looking in the right place.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

製品

リリース

R2018b

タグ

質問済み:

2020 年 1 月 13 日

コメント済み:

2020 年 1 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by