PHP regular expression filters html tag attributes (DEMO) and regular expression demo. PHP regular expression filters html tag attributes (DEMO). Regular expression demo filters html tags. there can be built-in functions in php, but the filter is
Example 1For news content or blog articles, if the abstract is displayed, you need to remove the html format tag of the content, find a regular expression, and implement: The code is as follows:Copy code /*** Delete the html format in the input
The day before yesterday, Tianyuan made a batch modification to the content of his blog post. due to bugs in the source program, many backslashes in the path or code were removed. this problem was discovered only yesterday when bankw3000 posted a
Compare compares the content of strings and determines whether some characters are equal based on the cultural background (location ).
CompareOrdinal is the same as Compare, but does not consider the cultural background.
Format: a string containing
PHP Regular Expression filters html tag attributes (DEMO), regular expression demo
Html Tag filtering can have built-in functions in php, but the filtering is too clean. We sorted out some examples of using regular expressions to filter specified
First, let's look at your own writing method. The code is as follows:Copy code Str_replace ("", '', str_replace (' ','', str_replace ('', '', $ vv )))The simplest method is to replace the two divs specified in the $ vv variable. Later, we found
The difference between servlet and JSP* There are no built-in objects in the servlet, the built-in objects in the original JSP must pass through the HttpServletRequest object, orHttpServletResponse object generation.* For static HTML tags, the
Style Rule Selector
Author: loncer More resources to learn: wwww.loncer.cn
HTML SelectorHTML tags are selector, so that in all CSS applications, all HTML tags will be displayed according to the defined statements.
class selector
PHP functions to filter HTML:
Strip_tags (String)
This will allow you to filter out all the HTML tags.
If you want to filter out all HTML tags except ", you can write this:
Strip_tags (String, "");
To filter all HTML tags except xxx, you can
Filtering HTML tags can have built-in functions in PHP, but it's too clean to filter, we've sorted out some examples of using regular to filter the specified HTML tags, as shown below.
Sometimes you need to filter out the extra tag attributes, such
1, get the link address on the webpage:String matchstring = @ "]+href=\s* (?: ' (? [^ ']+) ' |" " (? [^ ""]+) "| (? [^>\s]+)) \s*[^>]*> ";2, get the title of the page:String matchstring = @ " (? .*) ";3. Remove all HTML tags from the page:String
Filter HTML tags in PHP can have built-in functions, but it filtered too clean, we sorted out some use the regular to filter the specified HTML tag example, as shown below.
Sometimes it is necessary to filter out the extra tag attributes, such as
1. datetime numeric type
System. datetime currenttime = new system. datetime ();
1.1 take the current year, month, day, hour, minute, second
Currenttime = system. datetime. now;
1.2 get current year
Int year = currenttime. Year;
1.3 take the current
Filter HTML tags in PHP can have built-in functions, but it filtered too clean, we sorted out some use the regular to filter the specified HTML tag example, as shown below.
Sometimes it is necessary to filter out the extra tag attributes, such as
The full name of 1.JSP is Java Server Pages, the Chinese name is Java Servers page, it is a simplified servlet design, JSP technology is somewhat similar to ASP technology, it is in the traditional Web page HTML (Standard Universal Markup Language
Sometimes you need to filter out the extra tag attributes, such as the IMG tab that filters out all attributes except the SRC attribute, such as deleting titile alt attributes and some of the foot onclick properties.
For example, to filter all
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.