Take the 2-minute tour ×
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It's 100% free, no registration required.

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"

and this:

"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?

share|improve this question

closed as off topic by David Wallace, FumbleFingers, MετάEd, StoneyB, Kris Oct 3 '12 at 13:49

Questions on English Language & Usage Stack Exchange are expected to relate to English language and usage within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
I am aware that my code will actually insert a close quote in the multi-line example - as I said, this question is more about the rules themselves than about how to implement them. –  Niet the Dark Absol Oct 1 '12 at 23:14
    
@tchrist Yeah, I know. It will also have problems should it find nested quotes. A recursive regex may be needed... –  Niet the Dark Absol Oct 1 '12 at 23:17
    
It may help to check out how MS Word achieves this. (Or does it?) –  Kris Oct 2 '12 at 5:19

2 Answers 2

You are going to have trouble with people who use a straight double quote as an abbreviation either for seconds, or for inches.

  • "He's 5'11" tall," she remarked.
  • Bill explained, "I can't believe he ran the race in just 2'30"!"
  • Sue's mom said, "I was at 38d 54' 48.59" north by 107d 1' 39.05" west when I took the 'shot'."

Or with the other kind of quote:

  • 'He's 5'11" tall,' she remarked.
  • Bill explained, 'I can't believe he ran the race in just 2'30"!'
  • Sue's mom said, 'I was at 38d 54' 48.59" north by 107d 1' 39.05" west when I took the "shot".'

Besides your original posting of using primes in math, the only other example I can think of is people who use prime and double-prime for stress marks, like saying any of these, depending on the “system” they’ve chosen:

  • ar tic' u la" tion
  • ar tic" u la' tion
  • ar 'tic u "la tion
  • ar "tic u 'la tion

All of these are better done in Unicode, where you can say things like

  • Sue’s mom said, “I was at 38° 54′ 48.59″ north by 107° 1′ 39.05″ west when I took the ‘shot’.”
  • Sue’s mom said, ‘I was at 38° 54′ 48.59″ north by 107° 1′ 39.05″ west when I took the “shot”.’

And have it actually come out right. But if you are converting ASCII, there are just going to be errors sometimes.

share|improve this answer

The question is "Are there any other rules for quotes in use for dialogue that I have missed?"

Yes. In the case of nested quotes, matched single quotes should be used for the innermost text. For example, if one wants to quote a passage of text that consists partially, but not entirely of dialogue, this would be the proper punctuation:

"'Is there - is there balm in Gilead? - tell me - tell me, I implore!'  
         Quoth the raven, `Nevermore.'"

or this news headline, freshly posted by The Wall Street Journal a few moments ago (if I were to want to quote it):

"Justices Probe 'Alien Tort' Law"

This is proper usage in the U.S. and Canada. It is familiar to me. British and Australian usage may be different, such that the roles of single and double quotation marks are reversed. In other words, use double quotation marks on the nested text, and single quote marks to enclose the entire passage. In the example above, that would be:

'"Is there – is there balm in Gilead? – tell me – tell me, I implore!"
         Quoth the Raven "Nevermore."'

and similarly

'Justices Probe "Alien Tort" Law'

The choice of quotation marks for nesting is not a hard and fast rule though. It is sufficient as long as usage is consistent, and observes either form of nesting.

share|improve this answer
1  
Where's need for down vote here? And who is that style-pundit? –  Kris Oct 2 '12 at 5:17
    
@Kris xoxoxo and an oink of gratitude. –  Feral Oink Oct 6 '12 at 11:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.