I can not delete a range of words in a string

1

I made a function in PHP that returns the result of a POST and converts to a string using cURL. However, my code returns a lot of useless information. I wanted to manipulate the string so that I could erase all the useless information and leave only what is useful, ie delete everything that comes before the word " </SCRIPT> " in string .

I'm putting a piece of the string that I get (there's a lot more information before that). I wanted my string to be equal to what is contained in the interval between <dt><b><font color="maroon">como</font></b> and </table>

<SCRIPT LANGUAGE='JavaScript1.1'><!--
  var objForm = document.theform;
  var index = 0;
  objForm.text.value="como n\u00e3o amar uma pessoa t\u00e3o linda";

  objForm.text.focus();
  checkIt(objForm.parser, 'parse');

  checkIt(objForm.visual, 'niceline');

function getIndex(elemID, testValue){
  for(i=0; i<elemID.length; i++){
    if (elemID[i].value == testValue)
      return i;
  }
  return 0;
}

function checkIt(element, value) {
  if (element.length==1 || element.type=="checkbox"){
    element.checked=1;
    element.selected=1;
  }
  else if (element.length>1){
    index = getIndex(element, value);
    element[index].selected=1;
    element[index].checked=1;
  }
}
//-->
</SCRIPT>
      <dl>
<dt><b><font color="maroon">como</font></b> 

<font color="maroon">[como]</font>  &lt;rel&gt; &lt;ks&gt; <font color="blue"><b>ADV</b> </font> <font color="darkgreen">@ADVL&gt;</font> <font color="darkgreen"><b>@#FS-ADVL</font></b> <font color="darkgreen"><b>@#FS-N&lt;</font></b>
<dt><b><font color="maroon">não</font></b> 

<font color="maroon">[não]</font>  <font color="blue"><b>ADV</b> </font> <font color="darkgreen">@ADVL&gt;</font>
<dt><b><font color="maroon">amar</font></b> 

<font color="maroon">[amar]</font>  &lt;vt&gt; <font color="blue"><b>V</b> FUT 1/3S SUBJ VFIN </font> <font color="darkgreen">@FMV</font>
<dt><b><font color="maroon">uma</font></b> 

<font color="maroon">[um]</font>  &lt;arti&gt; <font color="blue"><b>DET</b> F S </font> <font color="darkgreen">@&gt;N</font>
<dt><b><font color="maroon">pessoa</font></b> 

<font color="maroon">[pessoa]</font>  &lt;H&gt; <font color="blue"><b>N</b> F S </font> <font color="darkgreen">@&lt;ACC</font>
<dt><b><font color="maroon">tão</font></b> 

<font color="maroon">[tão]</font>  &lt;dem&gt; &lt;quant&gt; <font color="blue"><b>ADV</b> </font> <font color="darkgreen">@&gt;A</font>
<dt><b><font color="maroon">linda</font></b> 

<font color="maroon">[lindo]</font>  <font color="blue"><b>ADJ</b> F S </font> <font color="darkgreen">@N&lt;</font>
<dt><b><font color="maroon">.</font></b> 

</dl>
  </td>
  <td>&nbsp;
      </td>
</tr>
</table>


<br>
<div style="text-align: center;">
<!--
<hr width="60%">
<b style="color: #800; font-size: 75%;">With the most recent Java update, Oracle has decided to set the default Java security settings to block all unsigned applets.
<br/>Until we can fix this on our end by signing the applets, you can lower your security settings from Control Panel -> Java -> Security and set the slider to Medium instead of High.
<br/>If something else isn't working properly, contact <a href="mailto:[email protected]">Tino Didriksen</a>.</b>
<br/>
-->
<hr width="60%">
<a href="/visl/about/">Copyright 1996-2015</a>
| <a href="/contact.html">Report a Problem / Contact Us</a>
<!-- | <a href="http://beta.visl.sdu.dk/visl/about/spgskema_en.html" title="Please fill out our survey on how you use the VISL site!">Visitor Questionnaire</a> -->
| <a href="/visl/pt/parsing/automatic/parse.php?print=1" rel="nofollow">Printable Version</a>
<!--[if IE]>
<br><br>

What function do I use to be able to manipulate this string and exclude this useless information?

    
asked by anonymous 27.08.2015 / 16:39

2 answers

0

The @Will solution looks good, but it takes what's inside the tags, and I've made a simpler solution using:

substr : To get a substring; > strpos : To find the position of a substring.

It looks like this:

$str = "abc</SCRIPT>defgh";
$pos = "</SCRIPT>";

$rest = substr($str, strpos($str,$pos)+ strlen($pos));  // retorna "defgh"
    
27.08.2015 / 17:03
0

You could use a regular expression

link

At the site below you test your regular expression.

link

Simple example in javascript

Regular expression: ^ [] []

var r = /^[<]script[>](.+)[</]script[>]/;
r.exec('<script>teste</script>');
    
27.08.2015 / 16:50