Q: preg_replace to include a +, anything begins with string and ends with whitespace or period I'm having a DEVIL of a time getting the preg_replace to work! The pattern is that it starts with "so+" and then it should replace that plus everything following. 
so+FirstName, 
Your Reservation is confirmed for so+Date

Would be replaced with:
James,
Your Reservation is confirmed for July 1, 2017.

If it would help, I could use so: or so_ instead of the plus sign. But I need to replace anything that starts with that pattern, including what follows it, until it hits whitespace or a period.
EDIT: I've tried:
$search = '/\bso+([a-z]*)\b/i';
$search = '\bso+\w*\b';


A: + is a special character, if you want to match it in your string you must use \+.

A: try this it's work  fine, the problem just in + ,add slash to banalize it
<?php
$string="so+FirstName,Your Reservation is confirmed for so+Date";
$string = preg_replace('/\bso\+([a-z]*),\b/i', 'James', $string);
$string = preg_replace('/\bso\+Date\b/i', date('M d,Y'), $string);
echo $string;
?>

