Javascript - Xóa các thẻ HTML / XML khỏi chuỗi
Xóa các thẻ HTML / XML khỏi chuỗi
Ví dụ:
Mã nguồn:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JavaScript program to convert the letters of a given string in alphabetical order.</title>
</head>
<script>
function strip_html_tags(str)
{
if ((str===null) || (str===''))
return false;
else
str = str.toString();
return str.replace(/<[^>]*>/g, '');
}
document.write(strip_html_tags('PHP Exercises'));
</script>
<body>
</body>
</html>
Lưu đồ thuật toán: