Backend/PHP

html 태그 제거 정규식

Jeffrey Oh 2020. 5. 7. 19:16
if (isset($q)) {
    $q = trim($q);
    $q = preg_replace("/[\<\>\'\"\\\'\\\"\%\=\(\)\s]/", "", $q);
} else {
    $q = '';
}

혹은

$content = preg_replace("(\<(/?[^\>]+)\>)", "", $content);