/**
* 匹配<meta http-equiv='Content-Type' content='text/html; charset=GB18030'/>标签中的字符编码
* 的正则表达式
*/
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <p>
* Title: RegTest正则表达式测试类
* </p>
* <p>
* Description: 匹配<meta标签中的字符编码
* </p>
* <p>
* Copyright: Copyright (c) 2010
* </p>
* <p>
* Company:
* </p>
*
* @author <a href="hpjianhua@163.com">hpjianhua</a>
* @version 1.0
* @created 2010-10-04
*/
public class RegTest {
public static void main(String[] args) {
// 要匹配的字符串
String source = "<meta http-equiv='Content-Type' content='text/html; charset=GB18030'/>";
// 将上面要匹配的字符串转换成小写
source = source.toLowerCase();
// 匹配的字符串的正则表达式
String reg_charset = "<meta[^>]*?charset=([a-z|A-Z|0-9]*[\\-]*[0-9]*)[\\s|\\S]*";
Pattern p = Pattern.compile(reg_charset);
Matcher m = p.matcher(source);
while (m.find()) {
System.out.println(m.group(0));
System.out.println(m.group(1));
}
}
}
// outout:
// <meta http-equiv='content-type' content='text/html; charset=gb18030'/>
// gb18030
分享到:
相关推荐
<meta charset="utf-8"> <title>元旦倒计时代码</title> </head> <body > <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <h1 align="center">距离2024...
源代码<html> <head> <meta ... <li><dt>我的电脑</dt></li> <ol type="circle"> <li>本地磁盘C:</li> <ol type="square"> 我的文档<br/> 我的收蒧 </ol> </dl> </ol>
charset=gb2312" language="java"%> <html> <%@ include file="inc/conn1.jsp"%> <%@ include file="top.jsp"%> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>计算机图书-...
<%@ page import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html...
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>登录</title> <style type="text/css"> ...
<meta charset="utf-8" /> <title>Grayscale Canvas Example</title> <script src="modernizr-2010.07.16dev.js"></script> </head> <body> <img src="logo.jpg" id="avatar" title="logo" alt="low_key" ...
<meta charset="UTF-8"> <title>标题标签</title> </head> <body> <!-- 1. HTML 官方提供了6级文本标题--> <h1>h1文本内容</h1> <h2>h2文本内容</h2> <h3>h3文本内容</h3> <h4>h4文本内容</h4> <h5>h5文本...
<targetPath>META-INF/resources</targetPath> <includes> <include>**/**</include> </includes> </resource> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory...
<meta charset="utf-8" /> <title>福彩</title> <style type="text/css"> body{ width:900px; margin:0px auto; } h1,p#luckyNumbers { margin-bottom: 2px; font-weight: bold; font-size: 40px; } </style>...
charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <% if(session.getAttribute(...
<meta charset="utf-8"> <title>HTML5 百科</title> </head> <body> <p align="center"> <a href="page01.html"> <img src="images/html5.jpg" alt="传智播客设计学院UI 设计师"/> </a> </p> </body> </html>...
charset=gb2312" language="java" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta ...
echo "<div class=result><ul><li><b>类别:<font color=red>遗失</font></b></li>\n"; }else { echo "<div class=result><ul><li><b>类别:<font color=blue>招领</font></b></li>\n"; } echo "<li><b>标题...
<meta charset="UTF-8"> <script type="text/javascript" src="Clock.js"></script> </head> <body> <canvas width='500' height='500' id='clock'></canvas> </body> <script> initClock('clock'); </...
<meta charset="UTF-8"> <title>HTML练习题一</title> </head> <body> <p>这是一个例子,其中<span style="color:red; font-size:3em;">这段文字</span>需要显示为红色并且字号为3。</p> </body> </html> ``` ##...
<li class="item2"><a href="#" class="title"><img src="images/所有污染源列表查询.gif" />全部污染源</a></li> <li class="item2"><a href="#" class="title" onclick="fold(this);return false;"><img ...
### JSP标签 `<meta>` 的作用详解 在探讨 `<meta>` 标签的功能与应用之前,我们先简单回顾一下 `<meta>` 标签的基本概念。`<meta>` 标签是 HTML 中的一个元数据(metadata)标签,它用于提供关于 HTML 文档的信息,...
<meta charset="utf-8"> <title>demo</title> </head> <body> <!-- <strong></strong> <em></em> <pre></pre>格式化原样式输出 --> <br><br> <table border="1" cellspacing="0" cellpadding="5" align="center" ...
<meta charset="UTF-8"> <title>我的网页标题</title> <meta name="description" content="这是一个网页的简短描述"> </head> ``` 在网页设计中,CSS(Cascading Style Sheets)通常与HTML结合使用,以控制元素...