Issue
i have full string like this:
Route::post('asdasdasdad/{param1}/{param2}', 'Admin\RouteController@a212e12e');
.
and want to delete that route so in preg_replace
i focus on
Route::post('asdasdasdad
as start text and
Admin\RouteController@a212e12e');
as last text.
here what i try
preg_replace("/Route::post('asdasdasdad\(.*Admin\RouteController@a212e12e');\s*/s", "", $string);
but its not working.
Solution
you have some errors in your regex, some un-escaped regex characters. try this
preg_replace("/Route::post\('asdasdasdad.*Admin\\\\RouteController@a212e12e'\);\s*/s", "", $string);
if you want to replace multiple lines in one go
preg_replace_all("/Route::post\('asdasdasdad.*Admin\\\\RouteController@a212e12e'\);\s*/s", "", $string);
witch works as if you add the multi line
modifier to your regex
$string = file_get_contents('route.php');
$string = preg_replace("/Route::post\('asdasdasdad.*Admin\\\\RouteController@a212e12e'\);\s*/s", "", $string);
echo $string;
you get the line with EOL
removed
Answered By - N69S Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.