Please help with Regular Expression ..

1 次查看(过去 30 天)
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 ?

采纳的回答

Vishal Rane
Vishal Rane 2012-11-30
Change the pattern to '<black>\w+</black>'.
  2 个评论
Yowh
Yowh 2012-11-30
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 2012-11-30
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by