php - valid regEx expression in ereg_replace makes nothing -
this question has answer here:
- replace ereg_replace preg_replace 4 answers
i'm using php 5.2.17. want remove surplus data json string , i've thought can use replace function so. i'm using ereg_replace next expression:
'^.*?(?=\"created_at)'
which i've validated @ http://www.regexpal.com. i've pasted json string in there , match right. however, when make call:
$tweets = eregi_replace('^.*?(?=\"created_at)', $temp, 'something');
and echo $tweets variable, there's output. no errors in console neither. apache error log, however, complains error called reg_badrpt. there's comment in php docs of eregi_replace suggesting can due need escape special characters, i've escaped " character. , i've tried escape others no different behavior.
where problem then?
i don't think ereg
supports lookarounds. preg_replace
exists in php 5.2, should use instead. work expression delimiters.
$tweets = preg_replace('@^.*?(?=\"created_at)@i', 'something', $temp);
Comments
Post a Comment