Skip to content

Instantly share code, notes, and snippets.

@tom--
Last active December 15, 2015 20:29
Show Gist options
  • Select an option

  • Save tom--/5318833 to your computer and use it in GitHub Desktop.

Select an option

Save tom--/5318833 to your computer and use it in GitHub Desktop.
Cleaning up stray & chars in a verkakte XML input document.
<?php
$input = preg_replace(
'{& (?! \#x[\da-f]{2,6} ; )
(?! \#\d{3,6} ; )
(?! [a-z0-9]{2,16} ; )
}xiu',
'&amp;',
$input
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment