Skip to content

Instantly share code, notes, and snippets.

@pypt
Created December 20, 2011 16:04
Show Gist options
  • Save pypt/1502084 to your computer and use it in GitHub Desktop.
Save pypt/1502084 to your computer and use it in GitHub Desktop.
Change "quotes" to „quotes“
<?php
$text = 'Labas, aš "esu" Linas.';
$ws = '\s/\#~:+=&%@\-\x28\x29\]\[{}><"\''; // whitespace
$punc = ';,\.?!'; // punctuation
$text = preg_replace("#(?<=^|[$ws])\"(?=[^$ws$punc])#", '„', $text);
$text = preg_replace("#\"#", '“', $text);
echo $text; // Labas, aš „esu“ Linas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment