FILTER_SANITIZE_STRING et REGEX gestion des apostrophes
Bonjour à tous et à toutes.
J'ai un soucis, avec une regex. Je veux contrôler ce que l'utilisateur entre dans le champ d'un formulaire et y autoriser les apostrophes.
or j'utilise ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?php
// CLean all POST and GET
if(($_SERVER['REQUEST_METHOD'] == 'POST') && !empty($_GET)){
// we trim all the post array
$_POST = array_map('trim', $_POST);
//Strip tags, optionally strip or encode special characters.
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
}
if(($_SERVER['REQUEST_METHOD'] == 'GET') && !empty($_GET)){
// we trim all the post array
$_GET = array_map('trim', $_GET);
//Strip tags, optionally strip or encode special characters.
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
} |
et le FILTER_SANITIZE_STRING, change mon apostrophe en $, si j'ai bien compris et donc ma variable ne match plus la regex suivante.
Code:
1 2 3 4 5 6 7 8 9 10
|
function name_validation_regex($text){
if(preg_match ('/^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪÝŻŹÑßÇÆČ∂ð ,.\']+$/', $text)){
return TRUE;
}else{
return FALSE;
}
} |
Je bloque dessus et j'ai essayé plusieurs solutions mais rien n'y fait.
Merci d'avance.