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

3 次查看(过去 30 天)
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))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by