php - valid regEx expression in ereg_replace makes nothing -


this question has answer here:

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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -