Hey guys I'm here again with another problem. I want to search in a string for a string with quotes in it.


String to search = {'  </a></div></div></div><div class="clearfix"><table cellspacing="0" class="wsod_quoteData"><tr><td class="wsod_last wsod_lastIndex" nowrap="nowrap"  '}

What to search for = {'   <table cellspacing="0" class="wsod_quoteData">   '}
Then if found, from there, search for {'   </table>   '}

How can I search for the first string if it has quotes and spaces in it?

What I have so far:

//DataHolding is a string that contains the entire HTML file contents in it.

  size_t Start = DataHolding.find("<table cellspacing=\"0\"" " class=\"wsod_quoteData\">", 46);
  size_t End = DataHolding.find("</table>", Start, 8);

The strings never get found..

My PHP version (THIS WORKS):

$content = str_replace($newlines, "", html_entity_decode($raw));
$start = strpos($content,'<table cellspacing="0" class="wsod_quoteData">');
$end = strpos($content,'</table>',$start) + 8;
$table = substr($content,$start,$end-$start);

Edited 5 Years Ago by triumphost: n/a

A couple things come to mind:

1. you don't have to use the third parameter; it might be better to leave it out.


2. I can't remember all the characters that require escaping in a string sequence...have you tried searching for something simpler, like alpha text without any other characters?

I figured it out by trial and error..

size_t Start, End;
  Start = DataHolding.find("<table cellspacing=\"0\" class=\"wsod_quoteData\">");
  End = DataHolding.find("</table>", Start, 8);
  string Final = DataHolding.substr(Start, End-Start);     //From the Start Pos, Copy Everything Until the End Pos to a string..
This question has already been answered. Start a new discussion instead.