Ciao a tutti
In uno script php Ho una regexp in cui vorrei inserire un carattere speciale.
La regexp è:
$filter="/^[a-zA-Z0-9âèéêëòóôöüù-\s]+$/";
Ho provato a copiarlo e incollarlo ma il mio editor (edit plus) non me lo scrive e al suo posto usa un puntino.
Pensavo di inserire il carattere speciale nella regexp sotto forma di entità ma quando eseguo lo script php non me lo accetta.
Nel forum di regexp mi risponmdono così:
No you can't use entities but you can use the Unicode code points (You can do this with any character).
\u017C\u1E61\u1E93\u1E63\u1E62\u1E92
But I believe you have to turn on this capablity for PHP and syntax uses an 'x' instead of a 'u'
^[a-zA-Z0-9âèéêëòóôöüù-\x017C\x1E61\x1E93\x1E63\x1E62\x1E92]
NOTE: I just copied what you had only replacing on the syntax of a few characters so I don't know if you were trying to match a hyphen with the last hyphen in the pattern but if so that's not what will happen. A (rather large) range from ù to ż will be created
Michael
"In theory, theory and practice are the same. In practice, they are not."
Albert Einstein
Di conseguenza ho trasformato la mia regexp da come l'avevo fatta sopra a:
$filter="/^[a-zA-Z0-9âèéêëòóôöüù-\x017C\x1E61\x1E93\x1E63\x1E62\x1E92\s]+$/";
Ma i caratteri aggiunti ovvero:
\x017C
\x1E61
\x1E93
\x1E63
\x1E62
\x1E92
non vengono interpretati e preg_match non li riconosce.
La pagina in cui dovrebbe lavorare è salvata utf-8 e l'header è:
<?PHP
mb_internal_encoding("UTF-8");
Header('Content-Type: text/html; charset: utf-8');
Che faccio?
Grazie