Locate entire word in cell given a specific pattern

1 visualización (últimos 30 días)
GEORGIOS BEKAS
GEORGIOS BEKAS el 22 de En. de 2018
Comentada: Birdman el 22 de En. de 2018
I am trying to locate an entire word in a cell, given a specific pattern.
I am giving the following example:
stringList = {'cell', 'bell', 'charm', 'eva'}
index = find(strcmp(strList, 'ell'))
The words 'bell' and 'cell' must be located.

Respuesta aceptada

Birdman
Birdman el 22 de En. de 2018
regexp(strjoin(stringList),'[ell]')
  2 comentarios
GEORGIOS BEKAS
GEORGIOS BEKAS el 22 de En. de 2018
can you also explain that to me? :)
Birdman
Birdman el 22 de En. de 2018
Yes sure:)
Firstly, strjoin command gathers the content of the cell array within a character array so that it becomes proper to apply some calculations on it. Then, regexp command takes the first argument as converted, second argument means that it will search the entire input whether there are characters containing ell expression or not.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by