In PHP I am trying to replace anything that isn't a character (a-z and æ, ø and å) using this function:
$word = preg_replace('/[^a-z]/i', '', $word);
However, this will also replace the danish characters of æ, ø and å.
Testing different online tools using:
/[^a-zæøå]/i'
Yields the result I'm after, but using this in my PHP:
$word = preg_replace('/[^a-z]/i', '', $word);
Does not yield my expected result. I hope someone may be able to explain why that is, and what I should change to get the expected behavior.
Test data:
Cykeltøj
Shouldn't
abæøå
Expected output:
Cykeltøj
Shouldnt
abæøå
Actual output in the first function:
Cykeltj
Shouldnt
ab
Actual output in the second function
*nothing*
*nothing*
*nothing*