OR condition in regexp
11 views (last 30 days)
Show older comments
Hi all, i've a problem here when checking for the regular expression of strings in a cell.
Let
x = {'width = "13" height = "2"'
'width = "12" height = "90"'
'width = "2" height="5"'
'width = "0" height="5"'
'width = "20" height="5"'
'width = "1" height="0"'
'width = "20" height="50"'};
I use this two statement to find the width and height which smaller than 10.
width = find(~cellfun('isempty',regexp(html_only, 'width\s?=\s?"\s?[0-9]\s?"', 'match')));
height = find(~cellfun('isempty',regexp(html_only, 'height\s?=\s?"\s?[0-9]\s?"', 'match')));
How to make it to check for either width or height is smaller than 10. I code like this, but it cant work, and error prompted out.
width = find(~cellfun('isempty',regexp(html_only, 'width\s?=\s?"\s?[0-9]\s?"' | 'height\s? =\s?"\s?[0-9]\s?"', 'match')));
0 Comments
Answers (1)
Jos (10584)
on 10 Apr 2014
Again , approach this in two steps. First extract the numbers and then apply the condition.
As you have found out, it is much harder to code this in a single obfuscated line ...
2 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!