How do I determine if a word has a certain character in it?

7 visualizaciones (últimos 30 días)
How do I determine if a word has a certain character in it?
For example if I have a word ?????? and want to know if the letter c is in it?

Respuesta aceptada

TastyPastry
TastyPastry el 4 de Nov. de 2015
Editada: TastyPastry el 4 de Nov. de 2015
If you only want to know whether or not the letter is in the word...
hasLetter = any(myWord == 'c');

Más respuestas (1)

Image Analyst
Image Analyst el 4 de Nov. de 2015
How about strfind()
index = strfind(string, 'c');

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by