I need to use preg_replace to append a query string on image paths for cache busting purposes.
Currently I am using the following, however it does not account for an edge case where image extensions already have a query string.
$html = preg_replace('/\.(jpg|png|gif|jpeg)/i', '.${1}?v=1', $html);
How can I exclude matches that are followed by a question mark?
Much thanks for any help.
https://stackoverflow.com/questions/67014349/php-preg-replace-image-extensions-that-arent-proceeded-by-a-question-mark April 09, 2021 at 10:38AM
没有评论:
发表评论