Borrar filtros
Borrar filtros

Please help with Regular Expression ..

2 visualizaciones (últimos 30 días)
Yowh
Yowh el 30 de Nov. de 2012
Help please
str = '<black><black>shoes'
ans = regexp(str,'.*?','match','ignorecase');
what ans i want is:
'shoes'
but instead i got this:
'<black><black>shoes'
how can i regexp that ?

Respuesta aceptada

Vishal Rane
Vishal Rane el 30 de Nov. de 2012
Change the pattern to '<black>\w+</black>'.
  2 comentarios
Yowh
Yowh el 30 de Nov. de 2012
it worked ! thanks :) but how about in this situation ?
str = 'shirt<black>shoes'
how can i get 2x1 cell that contains shirt and shoes ..
Vishal Rane
Vishal Rane el 30 de Nov. de 2012
The same command still works, although output is a 1x2 cell array. Use transpose operator ' to get a 2x1 output.
Refer Regular Expressions for a better understanding on this topic.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre String Parsing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by