Borrar filtros
Borrar filtros

combine two regexprep into one

1 visualización (últimos 30 días)
Vincent I
Vincent I el 3 de Jun. de 2013
Hi, I was wondering if I can reduce the two lines of code into one? Thank you
selected = regexprep(selected, ' ',' ');
selected = regexprep(selected, '<.*?>','');

Respuesta aceptada

Daniel Shub
Daniel Shub el 3 de Jun. de 2013
I have no idea what you are trying to do. My regex foo is weak, but I am pretty sure for your example you can just replace both lines with
selected = selected;
For a more general one line solution you could do
selected = regexprep(regexprep(selected, ' ',' '), '<.*?>','');
Are you trying to find a single regex expression that does the (non) replacement?
  2 comentarios
Vincent I
Vincent I el 3 de Jun. de 2013
duh... yeah that works thank you
Daniel Shub
Daniel Shub el 3 de Jun. de 2013
It may work, but I wouldn't do it. The way you have it is so much more readable and maintainable.

Iniciar sesión para comentar.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 3 de Jun. de 2013
Why bother?
That works and is likely easier to understand!
  1 comentario
Vincent I
Vincent I el 3 de Jun. de 2013
I'm trying to reduce the amount of code....

Iniciar sesión para comentar.

Categorías

Más información sobre Logical 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