Strfind doesn't find string

9 次查看(过去 30 天)
Hi everyone
I'm web scrapping using strfind but I can't find one string with spaces. Assume that part of my text is the following:
tempHTML2=' Área <strongclass="search-results-property-list__feature-value"> 65.0'
And I want this:
str14='Área <strongclass="search-results-property-list__feature-value">';
However, strfind(tempHTML2,str14) returns me blank. If I remove 'Área ', it returns the correct location of the string. If I look for just ' Área', it also finds correctly.
One issue could be the blank spaces. However, the tempHTML2 is constructed as follows:
tempHTML2=tempHTML;
tempHTML2(tempHTML2==' ')=[];
One issue is that tempHTML2 has blank spaces even after deleting them. The sum(ismember(tempHTML2,' ')) returns zero.
Thanks in advance,
  6 个评论
Walter Roberson
Walter Roberson 2016-6-1
Please attach a copy of the tempHTML2 (before blank removal), or post the URL.
hpramos4@gmail.com

This is the webpage: wp

These are the HTML codes (the part I need) with and without spaces. Both were scrapped with urlread.

There's something strange in this: when I open the tempHTML2 string and look manually for the string, there are spaces between "Área" (check the print attached). When I write it to a txt the spaces are gone.

Still, neither strfind or regexp works.

请先登录,再进行评论。

回答(1 个)

hpramos4@gmail.com
I've solved the problem using isspace() in the tempHTML function. Thank you all.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by