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일
If you're looking for an exact match, then it's strcmp you want, not contains.
find(strcmp(list, searchinput))

댓글 수: 1

Thanks Guillaume! I knew it'd be simple but wasn't looking in the right place.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters 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