In the function below, I want to match the keyword case insensitive (should match \"Blue Yoga Mats\" and \"blue yoga mats\")...
However, it currently only matches if the
You can also use T-Regx library:
replace($post->post_content)->callback('doReplace');
// ↑ Delimiters are not required
Also, use of $mykeyword might cause user-input characters to break your pattern. With T-Regx you can use Prepared Patterns and just build your pattern:
$mykeyword
// quoting unsafe characters
]);
$pattern->replace($post->post_content)->callback('doReplace');