Reputation: 1381
Updating the Question:
$li_text = $li->plaintext;
echo '<br>'.$li_text;
echo '<br>'.$li_text = preg_replace('/\:(.*?)\>/',':', $li_text);
$li
getting the Value "Qualification : School & Graduation > BE / B.Tech ( Engineering ) " //by using simple html DOM parsing from other websites
The output i am getting is
Qualification : School & Graduation > BE / B.Tech ( Engineering )
Qualification : School & Graduation > BE / B.Tech ( Engineering )
If i assign $li_text = "Qualification : School & Graduation > BE / B.Tech ( Engineering )"
then the REGEX is working fine.
Upvotes: 3
Views: 1484
Reputation: 1967
Your code is working fine. Please notice that preg_replace
doesn't change the subject (i.e. $str
) but returns a result.
preg_replace() returns an array if the subject parameter is an array, or a string otherwise.
If matches are found, the new subject will be returned, otherwise subject will be returned unchanged or NULL if an error occurred.
So:
preg_replace('/:(.*?)\>/',':', $str);
echo $str;
is wrong. But:
$str = preg_replace('/:(.*?)\>/',':', $str);
echo $str;
is working.
Upvotes: 2