combine two regexprep into one
2 ビュー (過去 30 日間)
古いコメントを表示
Hi, I was wondering if I can reduce the two lines of code into one? Thank you
selected = regexprep(selected, ' ',' ');
selected = regexprep(selected, '<.*?>','');
0 件のコメント
採用された回答
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 件のコメント
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!