I considered posting this on Stack Overflow, but I figure this question is more about English syntax than programming rules for it.
So, currently I have this:
$fancyquote = preg_replace('/"\b(.*?\b.?)(?:"|$)/m','“$1”',$input);
What this basically does is look for a (straight) quote that comes right before a word character (letter, number or underscore), followed by the string in the quote, and ending with either the end of a line, or another straight quote.
So this will work with:
The man said "Hello!"
"This is a whole line"
"I am going to talk for a long time, and tell the story of my life all the way until today, but I could also tell you about today if you like.
"Or maybe not. Let me just get on with it."
But not this:
x = x' + x"
Are there any other rules for quotes in use for dialogue that I have missed?