$s = "Hello %Jacob. I just went to see %Charlie today.";
$pattern = '#(\\B%\\w+\\b(?!%))#i';
if (preg_match_all($pattern, $s, $m)) {
foreach($m[1] as $name) {
$name = substr($name, 1);
$sql = 'INSERT INTO table VALUES("'. $name . '")';
// INSERT INTO table VALUES("Jacob")
// INSERT INTO table VALUES("Charlie")
}
}