This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Replace all instances of "car" with "semi" across entire website (case-preserving) | |
| function replace_car_with_semi($content) { | |
| return preg_replace_callback('/\bcar\b/i', function($match) { | |
| // Preserve original case pattern | |
| if (ctype_upper($match[0])) { | |
| return 'SEMI'; // CAR -> SEMI | |
| } elseif (ctype_upper($match[0][0])) { | |
| return 'Semi'; // Car -> Semi | |
| } | |
| return 'semi'; // car -> semi |