Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ben said "buttons, dear sir".
- I replied "Did you say 'buttons'?" to him.
- Ben said ``buttons, dear sir''.
- I replied ``Did you say `buttons'?'' to him.
- Ben said “buttons, dear sir”.
- I replied “Did you say ‘buttons’?”
- input: text+
- text: uquote|squote|dquote
- squote "'" text "'"
- dquote """ text """
- uquote: [contraction|.]+
- contraction: [A-Za-z]+ "'" [A-Za-z]+
- s/"(w)/``$1/g;
- s/'(w)/`$1/g;
- s/([w.?!])"/$1''/g;
- # A single or double quote before a word character, preceded
- # by start of line, whitespace or punctuation gets converted
- # to "`" or "``" respectively.
- $text =~ s{ ( ^ | [sp{IsPunct}] )( ['"] ) (?= w ) }
- { $2 eq '"' ? "$1``" : "$1`" }mgxe;
- # A double quote preceded by a word or punctuation character
- # and followed by whitespace or end of line gets converted to
- # "''". (Final single quotes are represented by themselves so
- # we don't need to worry about those.)
- $text =~ s{ (?<= [wp{IsPunct}] ) " (?= s | $ ) }
- { "''" }mgxe
- '([ w-]+)'", " `\1'
Add Comment
Please, Sign In to add comment