1
When creating a function that returns false
if there are repeated letters in a word, and true
if there is no following test passes with the characters:
$this->assertTrue(isIsogram('Heizölrückstoßabdämpfung'));
But fails the following test:
$this->assertFalse(isIsogram('éléphant'));
The function that is called is the following:
function isIsogram(string $text) {
$letters = array_filter(str_split(strtolower($text)), function($value) {
$v = preg_replace('/[^a-zA-Z]/i', '', $value);
return !empty($v);
});
$uniq = array_unique($letters);
$diff = array_diff_assoc($letters, $uniq);
return count($diff) > 0 ? false : true;
}
With letters in German the test is applied and passes normally however the letters é
are removed when used the preg_replace
, how can I apply this validation to characters we use in our language?
The problem is that it removes
é
orç
that?– rray
yes, there is no test with
ç
, but withé
yes...– RFL