package com.neroarc.blog.myblog.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author: fjx
* @date: 2019/4/15 10:33
* Descripe:
*/
public class HtmlUtil {
private static final String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式
private static final String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式
private static final String regEx_html = "<(?!pre|/pre)[^>]+>"; // 定义HTML标签的正则表达式
private static final String regEx_space = "\\s*|\t|\r|\n";//定义空格回车换行符
private static final String regEx_summary = "<[^>]+>";
private static final String regEx_pre = "(?<=<pre>).+?(?=</pre>)";
public static String delHTMLTag(String htmlStr) {
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
Matcher m_script = p_script.matcher(htmlStr);
htmlStr = m_script.replaceAll(""); // 过滤script标签
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
Matcher m_style = p_style.matcher(htmlStr);
htmlStr = m_style.replaceAll(""); // 过滤style标签
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
Matcher m_html = p_html.matcher(htmlStr);
htmlStr = m_html.replaceAll(""); // 过滤html标签
Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
Matcher m_space = p_space.matcher(htmlStr);
htmlStr = m_space.replaceAll(""); // 过滤空格回车标签
return htmlStr.trim(); // 返回文本字符串
}
public static String getTextFromHtml(String htmlStr){
htmlStr = delHTMLTag(htmlStr);
htmlStr = htmlStr.replaceAll(" ", "");
//htmlStr = htmlStr.substring(0, htmlStr.indexOf("。")+1);
return htmlStr;
}
public static String getSummary(String preStr){
Pattern p_pre = Pattern.compile(regEx_pre,Pattern.CASE_INSENSITIVE);
Matcher m_pre = p_pre.matcher(preStr);
preStr = m_pre.replaceAll("");
Pattern p_summary = Pattern.compile(regEx_summary,Pattern.CASE_INSENSITIVE);
Matcher m_summary = p_summary.matcher(preStr);
preStr = m_summary.replaceAll("");
return preStr;
}
public static void main(String[] args) {
String str = "\n" +
"<h4 id=\"h4-java-\"><a name=\"Java设计模式\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>Java设计模式</h4><h4 id=\"h4-u88C5u9970u8005u6A21u5F0F\"><a name=\"装饰者模式\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>装饰者模式</h4><h6 id=\"h6-component\"><a name=\"Component\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>Component</h6><pre><code class=\"lang-java\">public interface Component {\n" +
" void method();\n" +
"}\n" +
"</code></pre>\n" +
"<h6 id=\"h6-concrete\"><a name=\"Concrete\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>Concrete</h6><pre><code class=\"lang-java\">public class ConcreteComponent implements Component {\n" +
" @Override\n" +
" public void method() {\n" +
" System.out.println(\"ConcreteComponent方法\");\n" +
" }\n" +
"}\n" +
"</code></pre>\n" +
"<h6 id=\"h6-decorator\"><a name=\"Decorator\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>Decorator</h6><pre><code class=\"lang-java\">public class Decorator implements Component{\n" +
"\n" +
" private Component component;\n" +
"\n" +
" public Decorator(Component component){\n" +
" this.component = component;\n" +
" }\n" +
"\n" +
" @Override\n" +
" public void method() {\n" +
" component.method();\n" +
" }\n" +
"}\n" +
"</code></pre>\n" +
"<h6 id=\"h6-decoratora\"><a name=\"DecoratorA\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>DecoratorA</h6><pre><code class=\"lang-java\">public class DecoratorA extends Decorator {\n" +
"\n" +
" public DecoratorA(Component component){\n" +
" super(component);\n" +
" }\n" +
"\n" +
" @Override\n" +
" public void method() {\n" +
" super.method();\n" +
" methodA();\n" +
" }\n" +
"\n" +
" public void methodA(){\n" +
" System.out.println(\"DecoratorA方法\");\n" +
" }\n" +
"}\n" +
"</code></pre>\n" +
"<h6 id=\"h6-decoratorb\"><a name=\"DecoratorB\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>DecoratorB</h6><pre><code class=\"lang-java\">public class DecoratorB extends Decorator {\n" +
"\n" +
" public DecoratorB(Component component){\n" +
" super(component);\n" +
" }\n" +
"\n" +
" @Override\n" +
" public void method() {\n" +
" super.method();\n" +
" methodB();\n" +
" }\n" +
"\n" +
" public void methodB(){\n" +
" System.out.println(\"DecoratorB方法\");\n" +
" }\n" +
"}\n" +
"</code></pre>\n" +
"<h6 id=\"h6-u6D4Bu8BD5u7C7B\"><a name=\"测试类\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>测试类</h6><pre><code class=\"lang-java\">public class Test {\n" +
"\n" +
" public static void main(String[] args) {\n" +
" Component component = new DecoratorB(new DecoratorA(new ConcreteComponent()));\n" +
"\n" +
" component.method();\n" +
" }\n" +
"}\n" +
"</code></pre>\n" +
"<p>B调用A的method,A调用ConceteCompant的method,链式。</p>\n" +
"<p>装饰对象和真实对象有相同的接口。这样客户端对象就可以以和真实对象相同的方式和装饰对象交互</p>\n" +
"<p>装饰对象接收所有来自客户端的请求,把这些请求转发给真实对象。</p>\n" +
"<p>装饰对象可以在转发这些请求前或者后增加一些附加功能。</p>\n" +
"<h4 id=\"h4-u5355u4F8Bu8BBEu8BA1u6A21u5F0F\"><a name=\"单例设计模式\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>单例设计模式</h4><h5 id=\"h5--\"><a name=\"懒汉模式(调用时才创建实例):\" class=\"reference-link\"></a><span class=\"header-link octicon octicon-link\"></span>懒汉模式(调用时才创建实例):</h5><p>原型:</p>\n" +
"<pre><code class=\"lang-java\">public class LanHanMode {\n" +
"\n" +
" private static LanHanMode lanHanMode= null;\n" +
" private LanHanMode(){}\n" +
"\n" +
" public static LanHanMode getInstance(){\n" +
" if(lanHanMode==null){\n" +
" lanHanMode = new LanHanMode();//懒汉模式,线程不安全\n"
没有合适的资源?快使用搜索试试~ 我知道了~
使用SSM框架基于SpringBoot的个人博客.zip
共637个文件
js:239个
html:119个
java:103个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 90 浏览量
2024-05-18
16:51:10
上传
评论
收藏 40.32MB ZIP 举报
温馨提示
基于springboot的java毕业&课程设计
资源推荐
资源详情
资源评论
收起资源包目录
使用SSM框架基于SpringBoot的个人博客.zip (637个子文件)
AUTHORS 6KB
mvnw.cmd 6KB
amazeui.flat.css 325KB
amazeui.css 324KB
amazeui.flat.min.css 250KB
amazeui.min.css 249KB
editormd.css 76KB
editormd.min.css 60KB
editormd.preview.css 55KB
editormd.preview.min.css 44KB
ambiance.css 26KB
layer.css 14KB
fanIndex.css 13KB
skPlayer.css 10KB
space.css 9KB
user.css 9KB
link.css 8KB
codemirror.css 8KB
login.css 8KB
style.css 7KB
leaveMessage.css 6KB
archive.css 5KB
codemirror.min.css 5KB
admin.css 5KB
layer.css 5KB
mdn-like.css 5KB
solarized.css 5KB
article.css 4KB
daily.css 3KB
merge.css 3KB
edit.css 3KB
lint.css 3KB
xq-dark.css 3KB
head.css 3KB
lesser-dark.css 2KB
gallery.css 2KB
pastel-on-dark.css 2KB
xq-light.css 2KB
about.css 2KB
tomorrow-night-eighties.css 2KB
editormd.logo.css 2KB
erlang-dark.css 2KB
zenburn.css 2KB
normalize.css 2KB
twilight.css 2KB
midnight.css 2KB
vibrant-ink.css 2KB
mbo.css 2KB
base16-dark.css 2KB
base16-light.css 2KB
style.css 2KB
tern.css 2KB
3024-night.css 2KB
paraiso-dark.css 2KB
paraiso-light.css 2KB
tomorrow-night-bright.css 2KB
3024-day.css 2KB
blackboard.css 2KB
colorforth.css 2KB
editormd.logo.min.css 2KB
the-matrix.css 2KB
night.css 2KB
rubyblue.css 2KB
monokai.css 1KB
cobalt.css 1KB
simplescrollbars.css 1KB
category.css 1KB
eclipse.css 1KB
footer.css 995B
tag.css 968B
neo.css 932B
elegant.css 768B
neat.css 693B
show-hint.css 662B
pagination.css 559B
dialog.css 502B
tiki.css 440B
foldgutter.css 435B
tiddlywiki.css 220B
matchesonscrollbar.css 188B
fullscreen.css 116B
ambiance-mobile.css 103B
app.css 23B
fontawesome-webfont.eot 75KB
fontawesome-webfont.eot 59KB
editormd-logo.eot 1KB
loading@3x.gif 21KB
loading@2x.gif 16KB
loading.gif 8KB
loading-0.gif 6KB
loading-dark.gif 5KB
loading-2.gif 2KB
loading-1.gif 701B
.gitignore 268B
user.html 33KB
scala.html 28KB
index.html 22KB
index.html 17KB
archive.html 17KB
fanIndex.html 16KB
共 637 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
Nowl
- 粉丝: 1w+
- 资源: 3891
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功