国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) PHP regular filter code for html tags, spaces, and newlines

PHP regular filter code for html tags, spaces, and newlines

Mar 17, 2017 pm 03:37 PM
html tag php regular newline character space

$str=preg_replace("/\s+/", " ", $str); //過濾多余回車 
$str=preg_replace("/<[ ]+/si","<",$str); //過濾<__("<"號后面帶空格) 

$str=preg_replace("/<\!--.*?-->/si","",$str); //注釋 
$str=preg_replace("/<(\!.*?)>/si","",$str); //過濾DOCTYPE 
$str=preg_replace("/<(\/?html.*?)>/si","",$str); //過濾html標簽 
$str=preg_replace("/<(\/?head.*?)>/si","",$str); //過濾head標簽 
$str=preg_replace("/<(\/?meta.*?)>/si","",$str); //過濾meta標簽 
$str=preg_replace("/<(\/?body.*?)>/si","",$str); //過濾body標簽 
$str=preg_replace("/<(\/?link.*?)>/si","",$str); //過濾link標簽 
$str=preg_replace("/<(\/?form.*?)>/si","",$str); //過濾form標簽 
$str=preg_replace("/cookie/si","COOKIE",$str); //過濾COOKIE標簽 

$str=preg_replace("/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); //過濾applet標簽 
$str=preg_replace("/<(\/?applet.*?)>/si","",$str); //過濾applet標簽 

$str=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); //過濾style標簽 
$str=preg_replace("/<(\/?style.*?)>/si","",$str); //過濾style標簽 

$str=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); //過濾title標簽 
$str=preg_replace("/<(\/?title.*?)>/si","",$str); //過濾title標簽 

$str=preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); //過濾object標簽 
$str=preg_replace("/<(\/?objec.*?)>/si","",$str); //過濾object標簽 

$str=preg_replace("/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); //過濾noframes標簽 
$str=preg_replace("/<(\/?noframes.*?)>/si","",$str); //過濾noframes標簽 

$str=preg_replace("/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); //過濾frame標簽 
$str=preg_replace("/<(\/?i?frame.*?)>/si","",$str); //過濾frame標簽 

$str=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); //過濾script標簽 
$str=preg_replace("/<(\/?script.*?)>/si","",$str); //過濾script標簽 
$str=preg_replace("/javascript/si","Javascript",$str); //過濾script標簽 
$str=preg_replace("/vbscript/si","Vbscript",$str); //過濾script標簽 
$str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); //過濾script標簽 
$str=preg_replace("/&#/si","&#",$str); //過濾script標簽,如javAsCript:alert(

更多php正則過濾html標簽、空格、換行符的代碼相關(guān)文章請關(guān)注PHP中文網(wǎng)!

相關(guān)文章:

PHP最常用的正則表達式的詳解

php正則替換變量指定字符的方法

PHP正則表達式匹配替換與分割功能實例淺析

PHP開發(fā)技巧(十二)-常用PHP正則表達式的實例代碼詳解

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP format rows to CSV and write file pointer PHP format rows to CSV and write file pointer Mar 22, 2024 am 09:00 AM

This article will explain in detail how PHP formats rows into CSV and writes file pointers. I think it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. Format rows to CSV and write to file pointer Step 1: Open file pointer $file=fopen(&quot;path/to/file.csv&quot;,&quot;w&quot;); Step 2: Convert rows to CSV string using fputcsv( ) function converts rows to CSV strings. The function accepts the following parameters: $file: file pointer $fields: CSV fields as an array $delimiter: field delimiter (optional) $enclosure: field quotes (

The difference between full-width spaces and half-width spaces The difference between full-width spaces and half-width spaces Mar 25, 2024 pm 12:45 PM

The difference between full-width spaces and half-width spaces. When we use word processing software or edit text content, we sometimes encounter the concept of spaces. Space is a very basic element in typesetting and formatting text, but many people may not know the difference between full-width spaces and half-width spaces. In daily use, we may feel that full-width spaces and half-width spaces have different effects in different situations, but we may not be aware of the subtle differences. First of all, the difference between full-width spaces and half-width spaces is the width they occupy.

What does a space mean in mysql? What does a space mean in mysql? Jul 20, 2023 pm 05:17 PM

MySQL A space is a special character used to separate keywords, identifiers, values, and other statement elements. Spaces can be used in multiple locations in a SQL statement and usually do not affect the execution of the statement. The purpose of spaces: 1. Used to separate keywords and identifiers; 2. Used to separate operators and values; 3. Used to separate functions, columns and table aliases; 4. Used for indentation and alignment.

How to extract HTML tag content using regular expressions in Go language How to extract HTML tag content using regular expressions in Go language Jul 14, 2023 pm 01:18 PM

How to use regular expressions to extract HTML tag content in Go language Introduction: Regular expression is a powerful text matching tool, and it is also widely used in Go language. In the scenario of processing HTML tags, regular expressions can help us quickly extract the required content. This article will introduce how to use regular expressions to extract the content of HTML tags in Go language, and give relevant code examples. 1. Introduce related packages First, we need to import related packages: regexp and fmt. regexp package provides

How to remove HTML tags using Python regular expressions How to remove HTML tags using Python regular expressions Jun 22, 2023 am 08:44 AM

HTML (HyperTextMarkupLanguage) is a standard language for creating Web pages. It uses tags and attributes to describe various elements on the page, such as text, images, tables, links, etc. However, when processing HTML text, it is difficult to quickly extract the text content for subsequent processing. At this time, we can use regular expressions in Python to remove HTML tags to quickly extract plain text. In Python, regular tables

What is the use of ireport line breaks? What is the use of ireport line breaks? Dec 21, 2023 am 10:36 AM

In ireport, you can use line breaks to wrap text. A newline character is a special character used to indicate where text should break.

How to remove HTML tags from string in PHP? How to remove HTML tags from string in PHP? Mar 23, 2024 pm 09:03 PM

PHP is a commonly used server-side scripting language that is widely used in website development and back-end application development. When developing a website or application, you often encounter situations where you need to process HTML tags in strings. This article will introduce how to use PHP to remove HTML tags from strings and provide specific code examples. Why do you need to remove HTML tags? HTML tags are often included when processing user input or text obtained from a database. Sometimes we want to remove these HTML tags when displaying text

How to use spaces correctly in Go How to use spaces correctly in Go Mar 29, 2024 pm 03:42 PM

Go language is a simple, efficient, and highly concurrency programming language. It is an open source language developed by Google. In the Go language, the use of spaces is very important, it can improve the readability and maintainability of the code. This article will introduce how to use spaces correctly in Go language and provide specific code examples. Why you need to use spaces correctly In the programming process, the use of spaces is very important for the readability and beauty of the code. Appropriate use of spaces can make code clearer and easier to read, thus reducing

See all articles