Skip to content

Instantly share code, notes, and snippets.

View fuzzyfox's full-sized avatar

William Duyck fuzzyfox

View GitHub Profile
@fuzzyfox
fuzzyfox / removeTrailingWhiltespace.php
Created September 22, 2020 19:09
Remove trailing whitespace from an input string (multiline).
function removeTrailingWhitespace(string $string) : string
{
return preg_replace('/[ \t]+(\r?)$/m', '$1', $string);
}
// PHPUnit testcase for method
// public function testTestInternalRemoveTrailingWhitespace()
// {
// $this->assertSame(
// "\n some\r\n string\n\n\r\nto remove trailing\n whitespace from.\n\n",