필터 지우기
필터 지우기

combine two regexprep into one

조회 수: 1 (최근 30일)
Vincent I
Vincent I 2013년 6월 3일
Hi, I was wondering if I can reduce the two lines of code into one? Thank you
selected = regexprep(selected, ' ',' ');
selected = regexprep(selected, '<.*?>','');

채택된 답변

Daniel Shub
Daniel Shub 2013년 6월 3일
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
Vincent I
Vincent I 2013년 6월 3일
duh... yeah that works thank you
Daniel Shub
Daniel Shub 2013년 6월 3일
It may work, but I wouldn't do it. The way you have it is so much more readable and maintainable.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2013년 6월 3일
Why bother?
That works and is likely easier to understand!
  댓글 수: 1
Vincent I
Vincent I 2013년 6월 3일
I'm trying to reduce the amount of code....

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by