Here's what I'm trying:
I have a literal string like this: 'This is David's note'
I want to escape the single-quote between the d and s in David's but leave the leading and trailing single-quotes intact (another one of those things I thought would be easy). Here's what I've tried:
<?php
$note = "'This is David's note'";
$pattern = '/(?<=\w)\'(?=\w)/';
$replacement = "\'";
preg_replace($pattern,$replacement,$note);
echo $note; // Outputs 'This is David's note'
?>
Can the \w character class not be used with look ahead/behind assertions or am I approaching this completely the wrong way?