package com.whatratimes.util;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
/*
-----------程序说明-------------
程序名称:JAVA写的JUBB
程序作者:Redhat
发布时间:2003.5.23
主页:http://2002.buyionline.net
授权:免费、自由传播及自由修改但请保留原作者信息
版本:1.0
使用的时候最好转换成JAVABEAN,加入你和JAVA LIB中去.
*/
public class JUBB
{
public static JUBB jubb = new JUBB();
public static String getHTML(String ubb, int question_id)
{
return jubb.getAll(ubb, question_id);
}
public static String getNoTag(String ubb )
{
String s = ubb;
s = jubb.replace(s, "&", "&");
s = jubb.replace(s, "\"", """);
s = jubb.replace(s, "<", "<");
s = jubb.replace(s, ">", ">");
return s;
}
public static String getBrText(String ubb)
{
String s = ubb;
s = jubb.replace(s, "&", "&");
s = jubb.replace(s, "\"", """);
s = jubb.replace(s, "<", "<");
s = jubb.replace(s, ">", ">");
return jubb.ReBr(s);
}
String u_s = new String("haha");
String u_s1 = new String("haha");
Pattern u_p;
Matcher u_m;
CharSequence u_s2;
boolean result;
/** 得到转换后的所有JUBB代码 */
public String getAll(String ins, int question_id)
{
String s = ins;
s = this.replace(s, "&", "&");
s = this.replace(s, "\"", """);
s = this.replace(s, "<", "<");
s = this.replace(s, ">", ">");
s = this.ReColor(s);
s = this.ReImg(s, question_id);
s = this.ReUrl(s);
// s = this.ReFly(s);
s = this.ReEmail(s);
s = this.ReBold(s);
// s = this.ReSlope(s);
// s = this.ReDownLine(s);
// s = this.ReMove(s);
s = this.ReTxtUrl(s);
s = this.ReTxtEmail(s);
s = this.ReTxtSize(s);
// s = this.ReQuote(s);
// s = this.ReCode(s);
// s = this.ReSup(s);
// s = this.ReSub(s);
// s = this.ReDelLine(s);
// s = this.ReFliph(s);
// s = this.ReFlipv(s);
// s = this.ReShadow(s);
// s = this.ReGlow(s);
// s = this.ReBlur(s);
// s = this.ReSwf(s);
// s = this.ReRm(s);
// s = this.ReMp(s);
// s = this.ReSk(s);
// s = this.ReSound(s);
// s = this.ReInvert(s);
// s = this.ReXray(s);
// s = this.ReLi(s);
// s = this.ReLi1(s);
// s = this.ReLi2(s);
s = this.ReBr(s);
s = this.ReAlign(s);
// s = this.ReQt(s);
s = this.ReFace(s);
s = this.ReSpace(s);
return s;
}
/** 每个替换都需要用到的公共函数 */
public String replace(String strSource, String strFrom, String strTo)
{
String strDest = "";
int intFromLen = strFrom.length();
int intPos;
while ((intPos = strSource.indexOf(strFrom)) != -1)
{
strDest = strDest + strSource.substring(0, intPos);
strDest = strDest + strTo;
strSource = strSource.substring(intPos + intFromLen);
}
strDest = strDest + strSource;
return strDest;
}
//
// <font color="#FF0000">hhhhhh</font>
/** 转换URL([url=http://www.sina.com.cn]新浪[/url]) */
/** Color替换([color=#dbff00]aaaa[/color]) */
public String ReColor(String ins)
{
this.u_s1 = ins;
this.u_s = ins;
this.u_s2 = this.u_s1.subSequence(0, this.u_s1.length());
try
{
this.u_p = Pattern.compile("(\\[color=)([^\\]]+)(\\])(.+?)(\\[\\/color\\])", Pattern.CASE_INSENSITIVE);
this.u_m = this.u_p.matcher(this.u_s2);
this.result = this.u_m.find();
while (result)
{
this.u_s = this.replace(this.u_s1, this.u_m.group(1) + this.u_m.group(2) + this.u_m.group(3) + this.u_m.group(4) + this.u_m.group(5), "<font color='" + this.u_m.group(2) + "'>" + this.u_m.group(4) + "</font>");
this.u_s1 = this.u_s;
this.u_m.find();
}
} catch (Exception e)
{
}
return u_s;
}
/** IMG替换([img]http://domain.com/path/img.jpg[/img]) */
public String ReImg(String ins, int question_id)
{
this.u_s1 = ins;
this.u_s = ins;
this.u_s2 = this.u_s1.subSequence(0, this.u_s1.length());
try
{
this.u_p = Pattern.compile("(\\[img\\])(.+?)(\\[\\/img\\])", Pattern.CASE_INSENSITIVE);
this.u_m = this.u_p.matcher(this.u_s2);
this.result = this.u_m.find();
while (result)
{
this.u_s = this.replace(this.u_s1, this.u_m.group(1) + this.u_m.group(2) + this.u_m.group(3), "<img src=../CourseQuestion/"+ question_id +"/" + this.u_m.group(2) + " border=0>");
this.u_s1 = this.u_s;
this.u_m.find();
}
} catch (Exception e)
{
}
return u_s;
}
/** 图片底片效果([invert]img.jpg[/invert]) */
public String ReInvert(String ins)
{
this.u_s1 = ins;
this.u_s = ins;
this.u_s2 = this.u_s1.subSequence(0, this.u_s1.length());
try
{
this.u_p = Pattern.compile("(\\[invert\\])(.+?)(\\[\\/invert\\])", Pattern.CASE_INSENSITIVE);
this.u_m = this.u_p.matcher(this.u_s2);
this.result = this.u_m.find();
while (result)
{
this.u_s = this.replace(this.u_s1, this.u_m.group(1) + this.u_m.group(2) + this.u_m.group(3), "<table style=\"filter:invert\"><img src=" + this.u_m.group(2) + " border=0></table>");
this.u_s1 = this.u_s;
this.u_m.find();
}
} catch (Exception e)
{
}
return u_s;
}
/** 图片曝光效果([xray]img.jpg[/xray]) */
public String ReXray(String ins)
{
this.u_s1 = ins;
this.u_s = ins;
this.u_s2 = this.u_s1.subSequence(0, this.u_s1.length());
try
{
this.u_p = Pattern.compile("(\\[xray\\])(.+?)(\\[\\/xray\\])", Pattern.CASE_INSENSITIVE);
this.u_m = this.u_p.matcher(this.u_s2);
this.result = this.u_m.find();
while (result)
{
this.u_s = this.replace(this.u_s1, this.u_m.group(1) + this.u_m.group(2) + this.u_m.group(3), "<table style=\"filter:xray\"><img src=" + this.u_m.group(2) + " border=0></table>");
this.u_s1 = this.u_s;
this.u_m.find();
}
} catch (Exception e)
{
}
return u_s;
}
/** 转换URL([url]http://somedomain[/url]) */
public String ReUrl(String ins)
{
this.u_s1 = ins;
this.u_s = ins;
this.u_s2 = this.u_s1.subSequence(0, this.u_s1.length());
try
{
this.u_p = Pattern.compile("(\\[url\\])(.+?)(\\[\\/url\\])", Pattern.CASE_INSENSITIVE);
this.u_m = this.u_p.matcher(this.u_s2);
this.result = this.u_m.find();
while (result)
{
this.u_s = this.replace(this.u_s1, this.u_m.group(1) + this.u_m.group(2) + this.u_m.group(3), "<a href=" + this.u_m.group(2) + " target=_blank>" + this.u_m.group(2) + "</a>");
this.u_s1 = this.u_s;
this.u_m.find();
}
} catch (Exception e)
{
}
return u_s;
}
/** 转换URL([url=http://www.sina.com.cn]新浪[/url]) */
public String ReTxtUrl(String ins)
{
this.u_s1 = ins;
this.u_s = ins;
this.u_s2 = this.u_s1.subSequence(0, this.u_s1.length());
小菜源
- 粉丝: 710
- 资源: 363
最新资源
- Simulink仿真下的级联光伏发电MPPT追踪并网技术:探究MATLAB Simulink平台上的三个独立光伏发电系统级联并网技术参考文献讲解,Simulink仿真:级联光伏发电MPPT追踪并网 关
- FOC电流环模块实现指南:包含Park与Clark变换、id/iq PI控制等高级功能,配合SVPWM模块,详细说明书助你轻松掌握电流模式运行技术 ,FOC电流环模块进行,包含Park,Clark变
- Critic法计算指标权重并可视化展示MATLAB代码:指标数据的权重值求解与图形呈现,critic法计算指标权重 根据指标数据(每行是一个样本,每列是不同变量)计算各个指标的权重值并画图展示 MAT
- 高斯回归拟合x与y数据:自定义置信区间MATLAB代码详解及案例数据使用指南,高斯回归拟合x与y,带置信区间 置信区间可自定义 根据案例数据准备自己的自变量x与因变量y数据 按照相应格式替为自己数据即
- Qt OpenCV图像视觉框架:全套源码,工具可扩展,多相机多线程支持,模块化设计,Qt+OpenCV图像视觉框架全套源码上位机源码 工具可扩展 除了opencv和相机sdk的dll,其它所有算法均
- "加权拟合两个正态分布参数与比例详解:案例数据与修改指南",加权拟合2个正态分布参数与比例 一组数据可能由2个正态组合形成,可以进行拟合计算得到每组正态分布的参数与比例 matlab代码,根据自己需要
- 变频与移相混合控制LLC谐振变换器:全桥仿真与输出电压闭环的稳定波形研究,LLC,变频与移相混合控制,有参考文献 变频控制与移相控制组成的混合式控制全桥LLC谐振变器仿真(PFM+PSM混合控制)
- IMU与GPS融合定位技术:基于扩展卡尔曼滤波的机器人状态估计实现及运行说明,IMU与GPS融合定位,扩展卡尔曼滤波,cpp实现,机器人状态估计,有注释和运行说明 ,核心关键词:IMU与GPS融合定位
- 双峰高斯分布蒙特卡洛模拟:绘制PDF与CDF图,可调整分布比例与参数,Matlab代码示例,双峰高斯分布蒙特卡洛模并画pdf和cdf图 可设置双峰组合分布中不同正态参数的分布比例,也可以对多个组合进行
- 基于蒙特卡洛模拟的电动汽车充电负荷计算(Matlab实现,含充电时间、行驶里程分布分析,代码清晰易理解),基于蒙特卡洛抽样的电动汽车充电负荷计算(matlab代码版) 主要内容:代码主要主要研究的的是
- 基于粒子群算法的微网(风光燃储)优化调度策略与实现学习教程,MATLAB代码:基于粒子群算法的含风光燃储微网优化调度 关键词:微网优化调度 粒子群算法 风光燃储 参考文档:基于多目标粒子群算法的微
- 基于肘部法的K-means聚类算法实现:归一化数据、确定最佳聚类数并获取每类具体数据(Matlab代码),kmeans聚类,肘部法确定聚类个数 代码对数据先进行归一化然后聚类 可设定聚类个数范围,根据
- 基于P3分布参数拟合与ks检验的数据处理及可视化:累计概率密度图绘制与显著性水平设置matlab代码实战,P3分布参数拟合与ks检验,累计概率密度画图 对数据进行3参数拟合(形状、尺度、位置参数),可
- FLAC3D水力压裂案例研究:单孔与双孔模拟分析参考手册,FLAC3D水力压裂例子,可以拿来参考,有单孔和双孔 ,核心关键词:FLAC3D水力压裂; 单孔压裂; 双孔压裂; 参考例子 ,FLAC3
- 基于高频脉振电压注入的无感控制PMSM控制策略:位置观测器与转子信息提取方法探究,基于高频脉振电压注入的PMSM无传感器控制 无感控制,高频电压注入 1.包括位置观测器构成是带通滤波器加低通滤波器,采
- "拉锥光纤、镀膜与耦合技术:Rsoft beamprop光纤仿真与光子晶体光纤应用探索",拉锥光纤,镀膜、耦合、光栅…… Rsoft beamprop,光纤仿真,光子晶体光纤仿真 ,核心关键词:拉锥
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈