??xml version="1.0" encoding="utf-8" standalone="yes"?>不卡大黄网站免费看,韩国三级在线观看久,成人不用播放器http://www.aygfsteel.com/zeroline/All things are difficult before they are easy.zh-cnWed, 18 Jun 2025 06:17:00 GMTWed, 18 Jun 2025 06:17:00 GMT60JAVA代码验证w䆾证信?/title><link>http://www.aygfsteel.com/zeroline/archive/2011/01/03/342227.html</link><dc:creator>zeroline</dc:creator><author>zeroline</author><pubDate>Mon, 03 Jan 2011 12:56:00 GMT</pubDate><guid>http://www.aygfsteel.com/zeroline/archive/2011/01/03/342227.html</guid><wfw:comment>http://www.aygfsteel.com/zeroline/comments/342227.html</wfw:comment><comments>http://www.aygfsteel.com/zeroline/archive/2011/01/03/342227.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zeroline/comments/commentRss/342227.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zeroline/services/trackbacks/342227.html</trackback:ping><description><![CDATA[     摘要: Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->   1. /*********************************** w䆾证验证开?nbsp;***************...  <a href='http://www.aygfsteel.com/zeroline/archive/2011/01/03/342227.html'>阅读全文</a><img src ="http://www.aygfsteel.com/zeroline/aggbug/342227.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zeroline/" target="_blank">zeroline</a> 2011-01-03 20:56 <a href="http://www.aygfsteel.com/zeroline/archive/2011/01/03/342227.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Servlet生成验证码图?http://www.aygfsteel.com/zeroline/archive/2011/01/03/342226.htmlzerolinezerolineMon, 03 Jan 2011 12:51:00 GMThttp://www.aygfsteel.com/zeroline/archive/2011/01/03/342226.htmlhttp://www.aygfsteel.com/zeroline/comments/342226.htmlhttp://www.aygfsteel.com/zeroline/archive/2011/01/03/342226.html#Feedback0http://www.aygfsteel.com/zeroline/comments/commentRss/342226.htmlhttp://www.aygfsteel.com/zeroline/services/trackbacks/342226.html
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

public class Image extends HttpServlet {
 
public void doGet(HttpServletRequest request, HttpServletResponse response)
   
throws ServletException, IOException {
  response.setContentType(
"image/jpeg");
  OutputStream out 
= response.getOutputStream();
  response.setHeader(
"Pragma","No-cache"); 
  response.setHeader(
"Cache-Control","no-cache"); 
  response.setDateHeader(
"Expires"0);
  
int width = 60, height = 20;
  BufferedImage image 
= new BufferedImage(width, height,
    BufferedImage.TYPE_INT_RGB);
  
// 获取囑Ş上下?/span>
  Graphics g = image.getGraphics();
  
// 生成随机c?/span>
  Random random = new Random();
  
// 讑֮背景?/span>
  g.setColor(getRandColor(200250));
  g.fillRect(
00, width, height);
  
// 讑֮字体
  g.setFont(new Font("Times New Roman", Font.PLAIN, 18));
  
// 随机产生155条干扰线Q图象中的认证码不易被其它E序探测?/span>
  g.setColor(getRandColor(180200));
  
for (int i = 0; i < 155; i++) {
   
int x = random.nextInt(width);
   
int y = random.nextInt(height);
   
int xl = random.nextInt(12);
   
int yl = random.nextInt(12);
   g.drawLine(x, y, x 
+ xl, y + yl);
  }
  
// 取随Z生的认证?4位数?
  String sRand =setRandValue(request);
  
if(sRand!=null)
  
for (int i = 0; i < sRand.length(); i++) {
   g.setColor(
new Color(20 + random.nextInt(200), 20 + random
     .nextInt(
200), 20 + random.nextInt(200)));
   
// 调用函数出来的颜色相同,可能是因为种子太接近Q所以只能直接生?/span>
   g.drawString(sRand.charAt(i) + ""13 * i + 616);
  }
  
  JPEGImageEncoder encoder 
= JPEGCodec.createJPEGEncoder(out);
  encoder.encode(image);
  
// 图象生效
  g.dispose();
  
// 输出图象到页?br />   // ImageIO.write(image, "JPG", response.getOutputStream());
  out.flush();
  out.close();
 }

 Color getRandColor(
int fc, int bc) {// l定范围获得随机颜色
  Random random = new Random();
  
if (fc > 255)
   fc 
= 255;
  
if (bc > 255)
   bc 
= 255;
  
int r = fc + random.nextInt(bc - fc);
  
int g = fc + random.nextInt(bc - fc);
  
int b = fc + random.nextInt(bc - fc);
  
return new Color(r, g, b);
 }
 
//48-57对应0-9;65-90对应A-Z;97-122对应a-z;
 String setRandValue(HttpServletRequest request) {
  Random random 
= new Random();
  String sRand 
= "";
  
//q里是生成验证码的位?/span>
  for (int i = 0; i < 4; i++) {
   
char c = 0;
   
int k = random.nextInt(3);
   
switch (k) {
   
case 0:
    c 
= (char) (random.nextInt(10+ 48);
    
break;
   
case 1:
    c 
= (char) (random.nextInt(26+ 65);
    
break;
   
case 2:
    c 
= (char) (random.nextInt(26+ 97);
   }
   sRand 
+= c;
  }
  request.getSession().setAttribute(
"rands", sRand);
  
return sRand;
 }
}


zeroline 2011-01-03 20:51 发表评论
]]>
java.lang.IllegalArgumentException: Resources cannot be null.http://www.aygfsteel.com/zeroline/archive/2011/01/03/342224.htmlzerolinezerolineMon, 03 Jan 2011 12:33:00 GMThttp://www.aygfsteel.com/zeroline/archive/2011/01/03/342224.htmlhttp://www.aygfsteel.com/zeroline/comments/342224.htmlhttp://www.aygfsteel.com/zeroline/archive/2011/01/03/342224.html#Feedback0http://www.aygfsteel.com/zeroline/comments/commentRss/342224.htmlhttp://www.aygfsteel.com/zeroline/services/trackbacks/342224.html
	org.apache.commons.validator.Validator.<init>(Validator.java:188)
org.apache.struts.validator.Resources.initValidator(Resources.java:475)
org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:104)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:950)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:207)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

使用Struts1Q自己动手验证表单数据时Q出C如上的这个错?#8220;java.lang.IllegalArgumentException: Resources cannot be null.

”?br /> q是因ؓ在某个需要验证的 form 里,没有对validate()Ҏq行复写?br />




zeroline 2011-01-03 20:33 发表评论
]]>
javascript 触发事g列表 http://www.aygfsteel.com/zeroline/archive/2010/12/19/341087.htmlzerolinezerolineSun, 19 Dec 2010 02:31:00 GMThttp://www.aygfsteel.com/zeroline/archive/2010/12/19/341087.htmlhttp://www.aygfsteel.com/zeroline/comments/341087.htmlhttp://www.aygfsteel.com/zeroline/archive/2010/12/19/341087.html#Feedback0http://www.aygfsteel.com/zeroline/comments/commentRss/341087.htmlhttp://www.aygfsteel.com/zeroline/services/trackbacks/341087.html1.单击事g___onclick
用户单击鼠标按键时生的事g.同时onclick指定的事件处理程序或代码被调用执行.
?<input type="button" value="打开面" onlick="window.open('xxxx.html','newwindow','width=456,height=230,toolbar=no,menubar=no,scrollbars=yes');">
 
2.改变事g___onchange
当text或textarea元素内的字符值改变或select表格选项状态改变里发生该事?
?<textarea name="liuyan" rows=5 cols=70 value=" " onchange=alert("您在文本框中d了新的内?)>
 
3.选中事g____onselect
当text或textarea对象中的文字被选中里会引发该事?br /> ?<ipnut type="text" value="默认信息" onselect=alert("您选中了文本框中的文字")>
 
4.获得焦点事g____onfocus
用户单击text或textarea以及select对象?卛_标落在文本框或选择框时会生该事g.
?<select name="zhengjian" onfocus="alert("我成为焦?)>
 
5.失去焦点事g______onblur
失去焦点事g正好与获得焦点事件相?当text对象,textarea对象或select对象不再拥有焦点而退出后台时,引发该事?
 
6.载入文g事g____onload
当页面文件蝲入时,产生该事?onload的一个作用就是在首次载入一个页面文件时cookie的?q用一个变量ؓ其赋?使它可以被源代码使用,本事件是window的事?但是在HTML中指定事件处理程序时,一般把它写?lt;body>标记?
?<body onload=alert("正在加蝲面,L?..")>
 
7.卸蝲文g事g____onunload
与蝲入文件事件onload正好相反,当web面退出时引发的事?q可更新cookie的状?br /> ?<body onunload="confirm("你确定要d本页?")>
 
8.鼠标覆盖事g _____onmouseover
onmouseover是当鼠标位于元素上方时所引发的事?br /> ?<input type="boutton" value="按钮" onmouseover="window.status='h注意下面的状态栏'; return true">
 
9.鼠标d事g_____onmouseout
onmouseout是鼠标离开元素里引发的事g.如果和鼠标覆盖事件同时?可以创徏动态按钮的效果.
 
10.一般事?br /> ondbclick          鼠标双击事g
鼠标上的按键被按下时Ȁzȝ事g
鼠标按下?村ּ鼠标时触发的事g
鼠标Ud里触发的事g.
onkeypress       当键盘上的某个键被按下ƈ且释放时触发的事?要求面内必LȀzd?br /> onkeydown       当键盘上某个键被按下时触发的事g,要求面内必LȀzd?br /> onkeyup            当键盘上某个按键被放开时触发的事g,要求面内必LȀzd?br />  
11.面相关事g
onabort   囄在下载时被用户中?br /> onbeforeunload   当前面的内容将要被改变时触发的事g
onerror        捕捉当前面因ؓ某种原因而出现的错误,如脚本错?
onmove       览器的H口被移动里触发的事?br /> onresize     当浏览器的大被改变时触发的事g
onscroll         览器的滚动条位|发生变化时触发的事?br /> onstop          览器的"停止"按钮被按下或者正在下载的文g被中断时触发的事?
 
12. 表单相关事g
onreset      当表单中reset属性被ȀzL触发的事?
onsubmit  一个表单被递交时触发的事g.
 
13.滚动字幕事g
onbounce    当marquee内的内容Ud至marquee昄范围之外时触发的事g.
onfinish      当marquee元素完成需要显C的内容后触发的事g.
onstart        当marquee元素开始显C内Ҏ触发的事?
 
14.~辑事g.
onbeforecopy    当页面当前的被选择内容要复制到浏览者系l的剪脓板前触发的事?
onbeforeupdate  当浏览者粘贴系l剪贴板中的内容旉知目标对象
oncontextmenu   当按下鼠标右键出现菜单或通过键盘的按键触发页面菜单时触发的事?
                                <body oncontentmenu="return false">止使用鼠标右键
oncopy              当页面当前被选择内容被复制后触发的事?br /> oncut                  当页面当前被选择内容被剪切时触发的事?br /> onpaste               当内容被_脓时触发的事g
ondrag                当某个对象被拖动时触发的事g
ondragend          当鼠标拖动结束时触发的事?即鼠标的按键被释放时触发的事?
 
15.数据l定
onafterupdate    当数据完成由数据源到对象的传送时触发的事?br /> oncellchange      当数据来源发生变化时触发的事?br /> ondataavailable  当数据接收完成时触发的事?br /> ondatasetchanged   数据在数据源发生变化时触发的事g.
ondatasetcomplete   当数据源的全部有效数据读取完毕时触发的事?
onerrorupdate          当用onbeforeupdate事g触发取消了数据传送时,代替onafterupdate事g.
onrowenter               当前数据源的数据发生变化q且有新的有效数据时触发的事?
onrowexit                 当前数据源的数据要发生变化时触发的事g
onrowsdelete            当前数据记录被删除时触发的事g
onrowsinserted         当前数据源将要插入新数据记录时触发的事g
 
16.外部事g
onafterprint      当文被打印后触发的事g
onbeforeprint   当文即打印时触发的事?br /> onhelp              当浏览者按下F1键或者单L览器中的"帮助"按钮时触发的事g

zeroline 2010-12-19 10:31 发表评论
]]>
15ƾjs~辑器大?收藏http://www.aygfsteel.com/zeroline/archive/2010/12/19/341084.htmlzerolinezerolineSun, 19 Dec 2010 01:44:00 GMThttp://www.aygfsteel.com/zeroline/archive/2010/12/19/341084.htmlhttp://www.aygfsteel.com/zeroline/comments/341084.htmlhttp://www.aygfsteel.com/zeroline/archive/2010/12/19/341084.html#Feedback1http://www.aygfsteel.com/zeroline/comments/commentRss/341084.htmlhttp://www.aygfsteel.com/zeroline/services/trackbacks/341084.html

看了一?感觉不错,先收藏一?以后说不定有?

  1. 非常实用?63邮箱~辑? new163Editor.rar (395.12 KB)
  2. 2 soEditor v 2.5 lite

    官方: http://www.siteobjects.com/pages/index.cfm 下蝲: http://www.siteobjects.com/pages/order.cfm ?以下载的是lite? 目前q没扑ֈpro版的. 可以支持ASP,Coldfusion,ASP.NET. 界面做的很整z?但没有文件管?最大的问题是对于直接从其他处复制来的图片不会做自动修正.当然q个也仁者见仁了. soEditor 2.5 is an extremely powerful browser-based WYSIWYG content authoring tool

    designed specifically for dynamic web applications. This customizable editor allows

    developers to make it possible for anyone to create, edit and maintain web content

    without the need for HTML knowledge or programming expertise.

  3. AreaEdit V 0.4.2 演示: http://www.formvista.com/uploaded_html/demos/areaedit/examples/simple_example.php 下蝲: http://www.formvista.com/goalTracker/stream_download.php/14/areaedit_0.4.3.tar.gz 支持: http://www.formvista.com/forum ?改htmlarea的编辑器增加了图片文件管理器 htmlarea 作ؓ在线~辑器领域的开源作品n有不错的知名度有很多的支持者和插g开发?q些都得益于html良好的扩展? AreaEdit is a formVista compatible fork of the rapidly developing Xinha project.

    It is the code that is generated by the formVista FVML <htmleditor> tag during rendering. Xinha itself is a fork of the original HTMLArea component created by Mihai Bazon and

    sponsored by Interactivetools. AreaEdit maintains the original HTMLArea (modified BSD)

    license and is free to use. While it is designed to work within formVista without modification, AreaEdit does not

    requre formVista. It is a fully functional editor component supporting a number of

    plugins and can as easily be used as a standalone editor component for any PHP web

    application. The primary difference between AreaEdit and Xinha is one of focus. The Xinha project

    aims to be a rapidly developing feature-filled editor with many plugins. By contrast, AreaEdit takes a slower minimalists approach. It aims first and foremost

    to be functional and maintainable. The feature set we are focusing on is targeted

    squarely at the serious non-technical business user. Business users don&apos;t care

    about the nuances of HTML <br> and <p> tags, they just want the editor to work as

    they would expect. If your audience is primarly composed to developers or those familar with HTML, you

    should take a look at Xinha. AreaEdit is known to work with MSIE 5.5 or later and any modern Gecko based

    browsers. (FireFox, Mozilla).

  4. DevEdit Version 5.0.1 破解?/font> 官方|站: http://www.interspire.com 演示: http://www.interspire.com/devedit/demo.php 下蝲: http://bbs.80nian.net/thread-259-1-1.html?acdt=/devedit.rar 警告: 本程序是商业E序,仅供|友研究学习,请在下蝲?4时内删? 对于由此产生的法律问题本站概不负?/font>

  5. Web Wiz Rich Text Editor v3.0 下蝲: http://www.webwizguide.info/asp/sample_scripts/RTE_application.asp 演示: http://www.richtexteditor.org/demo/ 支持在线文g理,跨浏览器,但对表格~辑功能不强,界面不够_致 6

  6. KTML.Pro.v3.5.6-SPK100 下蝲: http://bbs.80nian.net/thread-259-1-1.html?acdt=/KTML_PRO-3.5.6.ZIP 警告: 本程序是商业E序,仅供|友研究学习,请在下蝲?4时内删? 对于由此产生的法律问题概不负? 有着cMdw一L属性栏,q个是pro?提供了lite版没有的对表格的属性编辑等功能,

    有兴的可以d方看看lite?

  7. TextArea Rich v3.0 下蝲: http://bbs.80nian.net/thread-259-1-1.html?acdt=/textarea.rich.v3.0.rar 做的很干净的编辑器,适合于CMS.功能强大.

  8. Tabula WYSIWYG HTML editor ver. 2.2 演示: http://www.tabula.biz/showArticle.asp?articleid=253 下蝲: http://www.tabula.biz/ShowArticle.asp?MID=5&ArticleID=257 和ewebsoft很像的编辑器右键功能强悍,界面做的E稍差了点点Q)

  9. TinyMCE 2.0RC3 官方|站: http://tinymce.moxiecode.com/ 官方演示: http://tinymce.moxiecode.com/example_full.php?example=true 下蝲: http://keihanna.dl.sourceforge.net/sourceforge/tinymce/tinymce_2_0RC3.zip 有一个很好的开源编辑器,界面,功能和可扩展性做的都很好

  10. |页在线~辑?mEditor ASP 中文?v2.0 下蝲: http://bbs.80nian.net/thread-259-1-1.html?acdt=/meditor.zip q?行环境支? 操作pȝ支持: Windows 2000 pd / Window Xp pd / Window 2003 pd|络服务器支? Asp 版本要求安装IIS 5.0版本或更高版?览器支? 正常q行在IE5.5以上版本,部分Ҏ功能要求IE版本升?.0以才能?>>> 在网l服务器讄完成?q行index.aspq行样式理. >>> mEditor攑֜目的根目录. 注意事项 有关无组件上传类 v2.0 升事项 1.修正内核部分字符~码的问? 2.增强pȝq行的健壮性与E_? 3.增加?模式按钮"栏式理,可随意启?取消模式按钮. 4.在编辑器的样式上q行了整体的修改. 5.增加了编辑器的羃攑֊?仅适用于IE5.5以上版本. 6.增加?搜烦替换"功能(快捷键CTRL+R),仅适用于IE5.5以上版本. 7.部分功能移植到"代码模式"使用,?"全?,"删除","复制"..... 8.增加快捷键CTRL+1(预览模式),CTRL+2(代码模式),CTRL+3(视图模式),CTRL+R(查找替换).

  11. EWELive JScript Editor 0.4 6 下蝲:  http://www.ewelive.com/downloads/0_64_JS.zip 我曾l仔l的L化过q个版本的编辑器,加了一些自q界面设计和按? 速度很快,功能单?Ҏ修改. 对于喜欢单一族的朋友可以下来看看. 官方: http://www.ewelive.com 演示: http://www.ewelive.com/demo_js/sample.php

  12. InnovaStudio WYSIWYG Editor v2.3 警告: 本程序是商业E序,仅供|友研究学习,请在下蝲?4时内删? 对于由此产生的法律问题概不负? 界面做的很是_, 功能极强?非常优秀之作,强烈推荐下蝲 http://www225.fixdown.com/code/sp-iwe23.rar

  13. CuteEditor for ASP Enterprise License 警告: 本程序是商业E序,仅供|友研究学习,请在下蝲?4时内删? 对于由此产生的法律问题概不负? Cuteditor 我曾研究q?不亏为成熟的商业作品,各方面做的都很规?功能强大,也提供简体中文语a?

    个h非常喜欢.强烈推荐 下蝲: http://bbs.80nian.net/thread-259-1-1.html?acdt=/CuteEditor_for_ASP_Enterprise_License.rar

  14. FCKeditor 2.6 _版第三版新增表格功能 http://bbs.80nian.net/viewthread.php?tid=158&highlight=FC

15 加一个新编辑器,不ؓ别的,漂亮 http://test.tstring.com.cn/sinaeditor/editor.htm



zeroline 2010-12-19 09:44 发表评论
]]>
C扑ַ作的时候,才知?本科 ?专科 的区?/title><link>http://www.aygfsteel.com/zeroline/archive/2010/11/29/339329.html</link><dc:creator>zeroline</dc:creator><author>zeroline</author><pubDate>Mon, 29 Nov 2010 08:18:00 GMT</pubDate><guid>http://www.aygfsteel.com/zeroline/archive/2010/11/29/339329.html</guid><wfw:comment>http://www.aygfsteel.com/zeroline/comments/339329.html</wfw:comment><comments>http://www.aygfsteel.com/zeroline/archive/2010/11/29/339329.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zeroline/comments/commentRss/339329.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zeroline/services/trackbacks/339329.html</trackback:ping><description><![CDATA[    11-25P一个在苏州的朋友跟几个同学Q一׃人)M家园区里?*公司参加W试应聘E序员的职位Q招聘信息上没有写限制条Ӟ只是在技术上作了一些要求? <p>    当这几个朋友兴冲冲的找了两个时扑ֈ?*公司Q他们对那边的环境不太熟悉)后,直接W试Q当天参加笔试的׃们三个hQ笔试之前没有作自我介绍?/p> <p>    ?*公司的HR把笔试的试题发下来后Q随口问了一句:“你们哪个学校毕业的?”</p> <p>    他们实话实说Q?#8221;q云?***学院“Q大专)</p> <p>    哪知那个HR直接_”我们不招大专生?#8220;随即把试题收了上去.......</p> <p>    我知道之后很是无语,只好安慰他。记着他,三五q之后,当这个hC公司应聘的时候,把他招进去,好好整他?/p> <p>    C扑ַ作的时候,才知道本U与大专的区别。或许有很多Z_学历不重要,只要有能力。但是现在的q个C会Q像q样的不留Q何情面的公司不在数。不? 整天的抱怨自q学校多么的不好,她终归还是个本科Q最L我们也能跟别的学校本U毕业生一Pv胸膛走进本科生专场招聘会?/p> <p>    然而进M后呢Q剩下的靠我们自己了!</p> <img src ="http://www.aygfsteel.com/zeroline/aggbug/339329.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zeroline/" target="_blank">zeroline</a> 2010-11-29 16:18 <a href="http://www.aygfsteel.com/zeroline/archive/2010/11/29/339329.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactoryhttp://www.aygfsteel.com/zeroline/archive/2010/11/21/338622.htmlzerolinezerolineSun, 21 Nov 2010 10:55:00 GMThttp://www.aygfsteel.com/zeroline/archive/2010/11/21/338622.htmlhttp://www.aygfsteel.com/zeroline/comments/338622.htmlhttp://www.aygfsteel.com/zeroline/archive/2010/11/21/338622.html#Feedback1http://www.aygfsteel.com/zeroline/comments/commentRss/338622.htmlhttp://www.aygfsteel.com/zeroline/services/trackbacks/338622.html
问题描述Q学?nbsp;Hibernate持久化技术时Q用hibernate-annotations-3.4.0.GA版本做实验,做好了程序和配置文g后,q行E序出现 java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory错误?br />
问题原因Qjar文g版本冲突

c?nbsp;org.slf4j.impl.StaticLoggerBinder在slf4j
-api 中是cȝ公有静态变?
public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
以上是在|络上找的答案,也有很多q的Q但是我遇到q个问题Ӟ使用的Hibernate?.6的,q种Ҏ不适合?br /> 后来我将 hibernate-jpa-2.0-api-1.0.0.Final.jar 包也加了q来之后Q程序就好了。具体原因还在纠l?img src="http://www.aygfsteel.com/Images/dot.gif" alt="" />.

而在slf4j
-log4j12Qslf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar其中之一Q中是U有变量:
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();

解决ҎQ?/span>1.修改slf的源代码Q将q个变量有私有改为公有,再打包,问题可解冟?br />
   
2.在类路径先将slf4j-api.jar 删除Q再导入同版本的slf4j-api-1.5.6.jar 和slf4j-log4j12-1.5.6.jar Q问题可解决?/span>
我遇到这个问题时用的是Hibernate3.6Q是hibernate-jpa-2.0-api-1.0.0.Final.jar包加q去才解决了的。相同问题的朋友试试?

zeroline 2010-11-21 18:55 发表评论
]]>
Servlet生成验证码图?/title><link>http://www.aygfsteel.com/zeroline/archive/2010/11/21/338597.html</link><dc:creator>zeroline</dc:creator><author>zeroline</author><pubDate>Sun, 21 Nov 2010 04:46:00 GMT</pubDate><guid>http://www.aygfsteel.com/zeroline/archive/2010/11/21/338597.html</guid><wfw:comment>http://www.aygfsteel.com/zeroline/comments/338597.html</wfw:comment><comments>http://www.aygfsteel.com/zeroline/archive/2010/11/21/338597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zeroline/comments/commentRss/338597.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zeroline/services/trackbacks/338597.html</trackback:ping><description><![CDATA[<span style="font-family: Courier;"> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.awt.Color;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.awt.Graphics;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.awt.image.BufferedImage;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.io.IOException;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.io.OutputStream;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> java.util.Random;<br /> <br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.servlet.ServletException;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.servlet.http.HttpServlet;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.servlet.http.HttpServletRequest;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> javax.servlet.http.HttpServletResponse;<br /> <br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> com.sun.image.codec.jpeg.JPEGCodec;<br /> </span><span style="color: #0000ff;">import</span><span style="color: #000000;"> com.sun.image.codec.jpeg.JPEGImageEncoder;<br /> <br /> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> ImageServlet </span><span style="color: #0000ff;">extends</span><span style="color: #000000;"> HttpServlet {<br /> <br />     </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> service(HttpServletRequest request, HttpServletResponse response)<br />             </span><span style="color: #0000ff;">throws</span><span style="color: #000000;"> ServletException, IOException {<br />         </span><span style="color: #008000;">//</span><span style="color: #008000;"> 讄响应cd</span><span style="color: #008000;"><br /> </span><span style="color: #000000;">        response.setContentType(</span><span style="color: #000000;">"</span><span style="color: #000000;">image/jpeg</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br />         </span><span style="color: #008000;">//</span><span style="color: #008000;"> 囄的内存映?/span><span style="color: #008000;"><br /> </span><span style="color: #000000;">        BufferedImage image </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BufferedImage(</span><span style="color: #000000;">50</span><span style="color: #000000;">, </span><span style="color: #000000;">20</span><span style="color: #000000;">,BufferedImage.TYPE_INT_RGB);<br />         </span><span style="color: #008000;">//</span><span style="color: #008000;"> 获得ȝ对象</span><span style="color: #008000;"><br /> </span><span style="color: #000000;">        Random r </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Random();<br />         Graphics g </span><span style="color: #000000;">=</span><span style="color: #000000;"> image.getGraphics();<br />         g.setColor(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Color(r.nextInt(</span><span style="color: #000000;">255</span><span style="color: #000000;">), r.nextInt(</span><span style="color: #000000;">255</span><span style="color: #000000;">), r.nextInt(</span><span style="color: #000000;">255</span><span style="color: #000000;">)));<br />         g.fillRect(</span><span style="color: #000000;">0</span><span style="color: #000000;">, </span><span style="color: #000000;">0</span><span style="color: #000000;">, </span><span style="color: #000000;">50</span><span style="color: #000000;">, </span><span style="color: #000000;">20</span><span style="color: #000000;">);<br />         g.setColor(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Color(</span><span style="color: #000000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">0</span><span style="color: #000000;">));<br />         String number </span><span style="color: #000000;">=</span><span style="color: #000000;"> String.valueOf(r.nextInt(</span><span style="color: #000000;">99999</span><span style="color: #000000;">)); <br />         g.drawString(number, </span><span style="color: #000000;">5</span><span style="color: #000000;">, </span><span style="color: #000000;">15</span><span style="color: #000000;">);<br /> <br />         </span><span style="color: #008000;">//</span><span style="color: #008000;"> 压羃成jpeg格式</span><span style="color: #008000;"><br /> </span><span style="color: #000000;">        OutputStream os </span><span style="color: #000000;">=</span><span style="color: #000000;"> response.getOutputStream();<br /> <br />         JPEGImageEncoder encoder </span><span style="color: #000000;">=</span><span style="color: #000000;"> JPEGCodec.createJPEGEncoder(os);<br /> <br />         </span><span style="color: #008000;">//</span><span style="color: #008000;"> 把BufferedImage对象中的囑փ信息~码?br />         </span><span style="color: #008000;">//</span><span style="color: #008000;"> 向创对象(encoder)时指定的输出输?/span><span style="color: #008000;"><br /> </span><span style="color: #000000;">        encoder.encode(image);<br />         <br />     }<br /> <br /> }<br /> </span></div> </span> <img src ="http://www.aygfsteel.com/zeroline/aggbug/338597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zeroline/" target="_blank">zeroline</a> 2010-11-21 12:46 <a href="http://www.aygfsteel.com/zeroline/archive/2010/11/21/338597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用MD5q行加密http://www.aygfsteel.com/zeroline/archive/2010/11/21/338596.htmlzerolinezerolineSun, 21 Nov 2010 04:43:00 GMThttp://www.aygfsteel.com/zeroline/archive/2010/11/21/338596.htmlhttp://www.aygfsteel.com/zeroline/comments/338596.htmlhttp://www.aygfsteel.com/zeroline/archive/2010/11/21/338596.html#Feedback0http://www.aygfsteel.com/zeroline/comments/commentRss/338596.htmlhttp://www.aygfsteel.com/zeroline/services/trackbacks/338596.html
加密Q?br /> getEncodeStr(String str) {
    
//定计算法
    MessageDigest md5 = MessageDigest.getInstance("md5") ;
    BASE64Encoder base64en 
= new BASE64Encoder() ;
    
    
//加密后的字符?/span>
    string = base64en.encode(md5.digest(str.getBytes("utf-8"))) ;
    
return string ;
}


验证密码是否一?/strong>Q?br />
if(getEncodeStr(newPassword).equals(oldPassword)){
    
return true ;
}
else{
    
return true ;
}


zeroline 2010-11-21 12:43 发表评论
]]>
l典 JavaScript 正则表达?/title><link>http://www.aygfsteel.com/zeroline/archive/2010/11/17/338312.html</link><dc:creator>zeroline</dc:creator><author>zeroline</author><pubDate>Wed, 17 Nov 2010 13:49:00 GMT</pubDate><guid>http://www.aygfsteel.com/zeroline/archive/2010/11/17/338312.html</guid><wfw:comment>http://www.aygfsteel.com/zeroline/comments/338312.html</wfw:comment><comments>http://www.aygfsteel.com/zeroline/archive/2010/11/17/338312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zeroline/comments/commentRss/338312.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zeroline/services/trackbacks/338312.html</trackback:ping><description><![CDATA[<p style="font-family: Courier"><span style="font-family: Courier">正则表达式用于字W串处理Q表单验证等场合Q实用高效,但用到时L不太把握Q以致往往要上|查一番。我一些常用的表达式收藏在q里Q作备忘之用?/span></p> <p><span style="font-family: Courier">匚w中文字符的正则表辑ּQ?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: olive">[</span><span style="color: gray">\</span><span style="color: blue">u4e00</span><span style="color: gray">-\</span><span style="color: blue">u9fa5</span><span style="color: olive">]</span></span></div> </div> <p><span style="font-family: Courier">匚w双字节字W?包括汉字在内)Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: olive">[</span><span style="color: gray">^\</span><span style="color: blue">x00</span><span style="color: gray">-\</span><span style="color: blue">xff</span><span style="color: olive">]</span></span></div> </div> <p><span style="font-family: Courier">应用Q计字W串的长度(一个双字节字符长度?QASCII字符?Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: teal">String</span><span style="color: gray">.</span><span style="color: blue">prototype</span><span style="color: gray">.</span><span style="color: blue">len</span><span style="color: gray">=</span><span style="color: green">function</span><span style="color: olive">(){</span><span style="color: gray"> </span><span style="color: green">return</span><span style="color: gray"> </span><span style="color: green">this</span><span style="color: gray">.</span><span style="color: blue">replace</span><span style="color: olive">([</span><span style="color: gray">^\</span><span style="color: blue">x00</span><span style="color: gray">-\</span><span style="color: blue">xff</span><span style="color: olive">]</span><span style="color: #8b0000">/</span><span style="color: red">g,"aa").length; }</span></span></div> </div> <p><span style="font-family: Courier">匚wI的正则表辑ּQ?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">\</span><span style="color: blue">n</span><span style="color: olive">[</span><span style="color: gray">\</span><span style="color: blue">s</span><span style="color: gray">|</span><span style="color: olive">]</span><span style="color: gray">*\</span><span style="color: blue">r</span></span></div> </div> <p><span style="font-family: Courier">匚wHTML标记的正则表辑ּQ?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: #8b0000">/</span><span style="color: red"><(.*)>.*<</span><span style="color: navy">\/</span><span style="color: red">\1>|<(.*) </span><span style="color: navy">\/</span><span style="color: red">></span><span style="color: #8b0000">/</span></span></div> </div> <p><span style="font-family: Courier">匚w首尾I格的正则表辑ּQ?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: olive">(</span><span style="color: gray">^\</span><span style="color: blue">s</span><span style="color: gray">*</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">(</span><span style="color: gray">\</span><span style="color: blue">s</span><span style="color: gray">*$</span><span style="color: olive">)</span></span></div> </div> <p><span style="font-family: Courier">应用Qj avascript中没有像v bscript那样的trim函数Q我们就可以利用q个表达式来实现Q如下:</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: teal">String</span><span style="color: gray">.</span><span style="color: blue">prototype</span><span style="color: gray">.</span><span style="color: blue">trim</span><span style="color: gray"> = </span><span style="color: green">function</span><span style="color: olive">()</span></span><span style="color: gray"><br /> </span><span style="color: olive"><span style="font-family: Courier">{</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="font-family: Courier"><span style="color: green">return</span><span style="color: gray"> </span><span style="color: green">this</span><span style="color: gray">.</span><span style="color: blue">replace</span><span style="color: olive">(</span><span style="color: #8b0000">/</span><span style="color: red">(^\s*)|(\s*$)</span><span style="color: #8b0000">/g</span><span style="color: gray">, </span><span style="color: #8b0000">""</span><span style="color: olive">)</span></span><span style="font-family: Courier"><span style="color: gray">;<br /> </span><span style="color: olive">}</span></span></div> </div> <p><span style="font-family: Courier">利用正则表达式分解和转换IP地址<br /> 下面是利用正则表辑ּ匚wIP地址QƈIP地址转换成对应数值的JavascriptE序Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: green">function</span><span style="color: gray"> </span><span style="color: blue">IP2V</span><span style="color: olive">(</span><span style="color: blue">ip</span><span style="color: olive">)</span></span><span style="color: gray"><br /> </span><span style="color: olive"><span style="font-family: Courier">{</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="font-family: Courier"><span style="color: blue">re</span><span style="color: gray">=</span><span style="color: #8b0000">/</span><span style="color: red">(\d+)\.(\d+)\.(\d+)\.(\d+)</span><span style="color: #8b0000">/g</span><span style="color: gray">  </span><span style="color: #ffa500">//匚wIP地址的正则表辑ּ</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="font-family: Courier"><span style="color: green">if</span><span style="color: olive">(</span><span style="color: blue">re</span><span style="color: gray">.</span><span style="color: blue">test</span><span style="color: olive">(</span><span style="color: blue">ip</span><span style="color: olive">))</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="color: olive"><span style="font-family: Courier">{</span></span><span style="color: gray"><br /> <span style="font-family: Courier">        </span></span><span style="font-family: Courier"><span style="color: green">return</span><span style="color: gray"> </span><span style="color: teal">RegExp</span><span style="color: gray">.$</span><span style="color: maroon">1</span><span style="color: gray">*</span><span style="color: teal">Math</span><span style="color: gray">.</span><span style="color: blue">pow</span><span style="color: olive">(</span><span style="color: maroon">255</span><span style="color: gray">,</span><span style="color: maroon">3</span><span style="color: olive">)</span><span style="color: gray">)+</span><span style="color: teal">RegExp</span><span style="color: gray">.$</span><span style="color: maroon">2</span><span style="color: gray">*</span><span style="color: teal">Math</span><span style="color: gray">.</span><span style="color: blue">pow</span><span style="color: olive">(</span><span style="color: maroon">255</span><span style="color: gray">,</span><span style="color: maroon">2</span><span style="color: olive">)</span><span style="color: gray">)+</span><span style="color: teal">RegExp</span><span style="color: gray">.$</span><span style="color: maroon">3</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">+</span><span style="color: teal">RegExp</span><span style="color: gray">.$</span><span style="color: maroon">4</span><span style="color: gray">*</span><span style="color: maroon">1</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="color: olive"><span style="font-family: Courier">}</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="color: green"><span style="font-family: Courier">else</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="color: olive"><span style="font-family: Courier">{</span></span><span style="color: gray"><br /> <span style="font-family: Courier">        </span></span><span style="font-family: Courier"><span style="color: green">throw</span><span style="color: gray"> </span><span style="color: green">new</span><span style="color: gray"> </span><span style="color: blue">Error</span><span style="color: olive">(</span><span style="color: #8b0000">"</span><span style="color: red">Not a valid IP address!</span><span style="color: #8b0000">"</span><span style="color: olive">)</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="color: olive"><span style="font-family: Courier">}</span></span><span style="color: gray"><br /> </span><span style="color: olive"><span style="font-family: Courier">}</span></span></div> </div> <p><span style="font-family: Courier">不过上面的程序如果不用正则表辑ּQ而直接用split函数来分解可能更单,E序如下Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">ip</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">10.100.20.168</span><span style="color: #8b0000">"</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: blue">ip</span><span style="color: gray">=</span><span style="color: blue">ip</span><span style="color: gray">.</span><span style="color: blue">split</span><span style="color: olive">(</span><span style="color: #8b0000">"</span><span style="color: red">.</span><span style="color: #8b0000">"</span><span style="color: olive">)</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: blue">alert</span><span style="color: olive">(</span><span style="color: #8b0000">"</span><span style="color: red">IP值是Q?/span><span style="color: #8b0000">"</span><span style="color: gray">+</span><span style="color: olive">(</span><span style="color: blue">ip</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">+</span><span style="color: blue">ip</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">+</span><span style="color: blue">ip</span><span style="color: olive">[</span><span style="color: maroon">2</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: maroon">255</span><span style="color: gray">+</span><span style="color: blue">ip</span><span style="color: olive">[</span><span style="color: maroon">3</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: maroon">1</span><span style="color: olive">))</span></span></div> </div> <p><span style="font-family: Courier">匚wEmail地址的正则表辑ּQ?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">+</span><span style="color: olive">([</span><span style="color: gray">-+.</span><span style="color: olive">]</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">*@\</span><span style="color: blue">w</span><span style="color: gray">+</span><span style="color: olive">([</span><span style="color: gray">-.</span><span style="color: olive">]</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">*\.\</span><span style="color: blue">w</span><span style="color: gray">+</span><span style="color: olive">([</span><span style="color: gray">-.</span><span style="color: olive">]</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">*</span></span></div> </div> <p><span style="font-family: Courier">匚w|址URL的正则表辑ּQ?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: blue">http</span><span style="color: gray">:</span><span style="color: #ffa500">//([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?</span></span></div> </div> <p><span style="font-family: Courier">利用正则表达式去除字串中重复的字W的法E序Q[*注:此程序不正确]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">s</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">abacabefgeeii</span><span style="color: #8b0000">"</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">s1</span><span style="color: gray">=</span><span style="color: blue">s</span><span style="color: gray">.</span><span style="color: blue">replace</span><span style="color: olive">(</span><span style="color: #8b0000">/</span><span style="color: red">(.).*\1</span><span style="color: #8b0000">/g</span><span style="color: gray">,</span><span style="color: #8b0000">"</span><span style="color: red">$1</span><span style="color: #8b0000">"</span><span style="color: olive">)</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">re</span><span style="color: gray">=</span><span style="color: green">new</span><span style="color: gray"> </span><span style="color: teal">RegExp</span><span style="color: olive">(</span><span style="color: #8b0000">"</span><span style="color: red">[</span><span style="color: #8b0000">"</span><span style="color: gray">+</span><span style="color: blue">s1</span><span style="color: gray">+</span><span style="color: #8b0000">"</span><span style="color: red">]</span><span style="color: #8b0000">"</span><span style="color: gray">,</span><span style="color: #8b0000">"</span><span style="color: red">g</span><span style="color: #8b0000">"</span><span style="color: olive">)</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">s2</span><span style="color: gray">=</span><span style="color: blue">s</span><span style="color: gray">.</span><span style="color: blue">replace</span><span style="color: olive">(</span><span style="color: blue">re</span><span style="color: gray">,</span><span style="color: #8b0000">""</span><span style="color: olive">)</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: blue">alert</span><span style="color: olive">(</span><span style="color: blue">s1</span><span style="color: gray">+</span><span style="color: blue">s2</span><span style="color: olive">)</span><span style="color: gray">  </span><span style="color: #ffa500">//l果为:abcefgi</span></span></div> </div> <p><span style="font-family: Courier">*?br /> ===============================<br /> 如果var s = “abacabefggeeii”<br /> l果׃对了Q结果ؓQabeicfgg<br /> 正则表达式的能力有限<br /> ===============================</span></p> <p><span style="font-family: Courier">我原来在CSDN上发贴寻求一个表辑ּ来实现去除重复字W的ҎQ最l没有找刎ͼq是我能惛_的最单的实现Ҏ。思\是用后向引用取出包括重复的字符Q再以重复的字符建立W二个表辑ּQ取C重复的字W,两者串q。这个方法对于字W顺序有要求的字W串可能不适用?/span></p> <p><span style="font-family: Courier">得用正则表达式从URL地址中提取文件名的javascriptE序Q如下结果ؓpage1</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: blue">s</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">http://blog.penner.cn/page1.htm</span><span style="color: #8b0000">"</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: blue">s</span><span style="color: gray">=</span><span style="color: blue">s</span><span style="color: gray">.</span><span style="color: blue">replace</span><span style="color: olive">(</span><span style="color: #8b0000">/</span><span style="color: red">(.*</span><span style="color: navy">\/</span><span style="color: red">){ 0, }([^\.]+).*</span><span style="color: #8b0000">/i</span><span style="color: blue">g</span><span style="color: gray">,</span><span style="color: #8b0000">"</span><span style="color: red">$2</span><span style="color: #8b0000">"</span><span style="color: olive">)</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: blue">alert</span><span style="color: olive">(</span><span style="color: blue">s</span><span style="color: olive">)</span></span></div> </div> <p><span style="font-family: Courier">利用正则表达式限制网表单里的文本框输入内容Q?/span></p> <p><span style="font-family: Courier">用正则表辑ּ限制只能输入中文Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: blue">onkeyup</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">value=value.replace(/[^\u4E00-\u9FA5]/g,'')</span><span style="color: #8b0000">"</span><span style="color: gray"> </span><span style="color: blue">onbeforepaste</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))</span><span style="color: #8b0000">"</span></span></div> </div> <p><span style="font-family: Courier">用正则表辑ּ限制只能输入全角字符Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: blue">onkeyup</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">value=value.replace(/[^\uFF00-\uFFFF]/g,'')</span><span style="color: #8b0000">"</span><span style="color: gray"> </span><span style="color: blue">onbeforepaste</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))</span><span style="color: #8b0000">"</span></span></div> </div> <p><span style="font-family: Courier">用正则表辑ּ限制只能输入数字Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: blue">onkeyup</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">value=value.replace(/[^\d]/g,'') </span><span style="color: #8b0000">"</span><span style="color: blue">onbeforepaste</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))</span><span style="color: #8b0000">"</span></span></div> </div> <p><span style="font-family: Courier">用正则表辑ּ限制只能输入数字和英文:</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: blue">onkeyup</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">value=value.replace(/[\W]/g,'') </span><span style="color: #8b0000">"</span><span style="color: blue">onbeforepaste</span><span style="color: gray">=</span><span style="color: #8b0000">"</span><span style="color: red">clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))</span><span style="color: #8b0000">"</span></span></div> </div> <p><span style="font-family: Courier">匚w非负整数Q正整数 + 0Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^\</span><span style="color: blue">d</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚w正整?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*$</span></span></div> </div> <p><span style="font-family: Courier">匚w非正整数Q负整数 + 0Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">((</span><span style="color: gray">-\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">(</span><span style="color: maroon">0</span><span style="color: gray">+</span><span style="color: olive">))</span><span style="color: gray">$</span></span></div> </div> <p><span style="font-family: Courier">匚w负整?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^-</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*$</span></span></div> </div> <p><span style="font-family: Courier">匚w整数</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^-?\</span><span style="color: blue">d</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚w非负点敎ͼ正QҎ + 0Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">(</span><span style="color: gray">\.\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">?$</span></span></div> </div> <p><span style="font-family: Courier">匚w正QҎ</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">(([</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">+\.</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">([</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*\.</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">([</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">))</span><span style="color: gray">$</span></span></div> </div> <p><span style="font-family: Courier">匚w非正点敎ͼ负QҎ + 0Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">((</span><span style="color: gray">-\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">(</span><span style="color: gray">\.\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">?</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">(</span><span style="color: maroon">0</span><span style="color: gray">+</span><span style="color: olive">(</span><span style="color: gray">\</span><span style="color: maroon">.0</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">?</span><span style="color: olive">))</span><span style="color: gray">$</span></span></div> </div> <p><span style="font-family: Courier">匚w负QҎ</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">(</span><span style="color: gray">-</span><span style="color: olive">(([</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">+\.</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">([</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*\.</span><span style="color: olive">[</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">|</span><span style="color: olive">([</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">[</span><span style="color: maroon">1</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">][</span><span style="color: maroon">0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">)))</span><span style="color: gray">$</span></span></div> </div> <p><span style="font-family: Courier">匚w点?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">(</span><span style="color: gray">-?\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">)(</span><span style="color: gray">\.\</span><span style="color: blue">d</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">?$</span></span></div> </div> <p><span style="font-family: Courier">匚w?6个英文字母组成的字符?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: blue">A</span><span style="color: gray">-</span><span style="color: blue">Za</span><span style="color: gray">-</span><span style="color: blue">z</span><span style="color: olive">]</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚w?6个英文字母的大写l成的字W串</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: blue">A</span><span style="color: gray">-</span><span style="color: blue">Z</span><span style="color: olive">]</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚w?6个英文字母的写l成的字W串</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: blue">a</span><span style="color: gray">-</span><span style="color: blue">z</span><span style="color: olive">]</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚w由数字和26个英文字母组成的字符?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: blue">A</span><span style="color: gray">-</span><span style="color: blue">Za</span><span style="color: gray">-</span><span style="color: blue">z0</span><span style="color: gray">-</span><span style="color: maroon">9</span><span style="color: olive">]</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚w由数字?6个英文字母或者下划线l成的字W串</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^\</span><span style="color: blue">w</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚wemail地址</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">-</span><span style="color: olive">]</span><span style="color: gray">+</span><span style="color: olive">(</span><span style="color: gray">\.</span><span style="color: olive">[</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">-</span><span style="color: olive">]</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">*@</span><span style="color: olive">[</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">-</span><span style="color: olive">]</span><span style="color: gray">+</span><span style="color: olive">(</span><span style="color: gray">\.</span><span style="color: olive">[</span><span style="color: gray">\</span><span style="color: blue">w</span><span style="color: gray">-</span><span style="color: olive">]</span><span style="color: gray">+</span><span style="color: olive">)</span><span style="color: gray">+$</span></span></div> </div> <p><span style="font-family: Courier">匚wurl</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray">^</span><span style="color: olive">[</span><span style="color: blue">a</span><span style="color: gray">-</span><span style="color: blue">zA</span><span style="color: gray">-</span><span style="color: blue">z</span><span style="color: olive">]</span><span style="color: gray">+:</span><span style="color: #ffa500">//匚w(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$</span></span></div> </div> <p><span style="font-family: Courier">匚whtml tag</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: gray"><\</span><span style="color: blue">s</span><span style="color: gray">*</span><span style="color: olive">(</span><span style="color: gray">\</span><span style="color: blue">S</span><span style="color: gray">+</span><span style="color: olive">)(</span><span style="color: gray">\</span><span style="color: blue">s</span><span style="color: olive">[</span><span style="color: gray">^></span><span style="color: olive">]</span><span style="color: gray">*</span><span style="color: olive">)</span><span style="color: gray">?></span><span style="color: olive">(</span><span style="color: gray">.*?</span><span style="color: olive">)</span><span style="color: gray"><\</span><span style="color: blue">s</span><span style="color: gray">*\</span><span style="color: #8b0000">/</span><span style="color: red">\1\s*></span></span></div> </div> <p><span style="font-family: Courier">Visual Basic & C# Regular Expression<br /> 1.认有效电子邮g格式<br /> 下面的示例用静?Regex.IsMatch Ҏ验证一个字W串是否为有效电子邮件格式。如果字W串包含一个有效的电子邮g地址Q则 IsValidEmail Ҏq回 trueQ否则返?falseQ但不采取其他Q何操作。您可以使用 IsValidEmailQ在应用E序地址存储在数据库中或昄?ASP.NET 中之前Q筛选出包含无效字符的电子邮件地址?/span></p> <p><span style="font-family: Courier">[Visual Basic]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">Function IsValidEmail(strIn As String) As Boolean<br /> ' Return true if strIn is in valid e-mail format.<br /> Return Regex.IsMatch(strIn, ("^([\w-\.]+)@((\[[0-9]{ 1,3 }\.[0-9]{ 1,3 }\.[0-9]{ 1,3 }\.)|(([\w-]+\.)+))([a-zA-Z]{ 2,4 }|[0-9]{ 1,3 })(\]?)$")<br /> End Function</span></div> </div> <p><span style="font-family: Courier">[C#]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">bool IsValidEmail(string strIn)<br /> {<br /> // Return true if strIn is in valid e-mail format.<br /> return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{ 1,3 }\.[0-9]{ 1,3 }\.[0-9]{ 1,3 }\.)|(([\w-]+\.)+))([a-zA-Z]{ 2,4 }|[0-9]{ 1,3 })(\]?)$");<br /> }</span></div> </div> <p><span style="font-family: Courier">2.清理输入字符?br /> 下面的代码示例用静?Regex.Replace Ҏ从字W串中抽出无效字W。您可以使用q里定义?CleanInput ҎQ清除掉在接受用戯入的H体的文本字D中输入的可能有害的字符。CleanInput 在清除掉?@?Q连字符Q和 .Q句点)以外的所有非字母数字字符后返回一个字W串?/span></p> <p><span style="font-family: Courier">[Visual Basic]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">Function CleanInput(strIn As String) As String<br /> ' Replace invalid characters with empty strings.<br /> Return Regex.Replace(strIn, "[^\w\.@-]", "")<br /> End Function</span></div> </div> <p><span style="font-family: Courier">[C#]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">String CleanInput(string strIn)<br /> {<br />     // Replace invalid characters with empty strings.<br />     return Regex.Replace(strIn, @"[^\w\.@-]", "");<br /> }</span></div> </div> <p><span style="font-family: Courier">3.更改日期格式<br /> 以下代码CZ使用 Regex.Replace Ҏ来用 dd-mm-yy 的日期Ş式代?mm/dd/yy 的日期Ş式?/span></p> <p><span style="font-family: Courier">[Visual Basic]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">Function MDYToDMY(input As String) As String<br /> Return Regex.Replace(input, _<br /> "\b(?<month>\d{ 1,2 })/(?<day>\d{ 1,2 })/(?<year>\d{ 2,4 })\b", _<br /> "${ day }-${ month }-${ year }")<br /> End Function</span></div> </div> <p><span style="font-family: Courier">[C#]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">String MDYToDMY(String input)<br /> {<br />     return Regex.Replace(input,"\\b(?<month>\\d{ 1,2 })/(?<day>\\d{ 1,2 })/(?<year>\\d{ 2,4 })\\b","${ day }-${ month }-${ year }");<br /> }</span></div> </div> <p><span style="font-family: Courier">Regex 替换模式<br /> 本示例说明如何在 Regex.Replace 的替换模式中使用命名的反向引用。其中,替换表达?${ day } 插入?(?…) l捕L子字W串?/span></p> <p><span style="font-family: Courier">有几U静态函C您可以在使用正则表达式操作时无需创徏昑ּ正则表达式对象,?Regex.Replace 函数正是其中之一。如果您不想保留~译的正则表辑ּQ这给您带来方?/span></p> <p><span style="font-family: Courier">4.提取 URL 信息<br /> 以下代码CZ使用 Match.Result 来从 URL 提取协议和端口号。例如,“http://www.penner.cn:8080……返?#8220;http:8080”?/span></p> <p><span style="font-family: Courier">[Visual Basic]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">Function Extension(url As String) As String<br /> Dim r As New Regex("^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/", _<br /> RegexOptions.Compiled)<br /> Return r.Match(url).Result("${ proto }${ port }")<br /> End Function</span></div> </div> <p><span style="font-family: Courier">[C#]</span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier">String Extension(String url)<br /> {<br />     Regex r = new Regex(@"^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/",<br />     RegexOptions.Compiled);<br />     return r.Match(url).Result("${ proto }${ port }");<br /> }</span></div> </div> <p><span style="font-family: Courier">只有字母和数字,不小?位,且数字字母都包含的密码的正则表达?br /> 在C#中,可以用这个来表示Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: #8b0000">"</span><span style="color: red">\w{ 6 }(\w+)*</span><span style="color: #8b0000">"</span></span></div> </div> <p><span style="font-family: Courier">一个将需要将路径字符串拆分ؓ根目录和子目录两部分的算法程序,考虑路径格式有:C:\aa\bb\cc Q\\aa\bb\cc Q?ftp://aa.bb/cc 上述路径分别被拆分为:C:\和aa\bb\cc Q\\aa ?\bb\cc Q?ftp:// ?aa.bb/cc 用javascript实现如下Q?/span></p> <div id="wmqeeuq" class="hl-surround"> <div id="wmqeeuq" class="hl-main"><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">strRoot</span><span style="color: gray">,</span><span style="color: blue">strSub</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: green">var</span><span style="color: gray"> </span><span style="color: blue">regPathParse</span><span style="color: gray">=</span><span style="color: #8b0000">/</span><span style="color: red">^([^\\^</span><span style="color: navy">\/</span><span style="color: red">]+[\\</span><span style="color: navy">\/</span><span style="color: red">]+|\\\\[^\\]+)(.*)$</span><span style="color: #8b0000">/</span></span><span style="color: gray"><br /> </span><span style="font-family: Courier"><span style="color: green">if</span><span style="color: olive">(</span><span style="color: blue">regPathParse</span><span style="color: gray">.</span><span style="color: blue">test</span><span style="color: olive">(</span><span style="color: blue">strFolder</span><span style="color: olive">))</span></span><span style="color: gray"><br /> </span><span style="color: olive"><span style="font-family: Courier">{</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="font-family: Courier"><span style="color: blue">strRoot</span><span style="color: gray">=</span><span style="color: teal">RegExp</span><span style="color: gray">.$</span><span style="color: maroon">1</span></span><span style="color: gray"><br /> <span style="font-family: Courier">    </span></span><span style="font-family: Courier"><span style="color: blue">strSub</span><span style="color: gray">=</span><span style="color: teal">RegExp</span><span style="color: gray">.$</span><span style="color: maroon">2</span></span><span style="color: gray"><br /> </span><span style="color: olive"><span style="font-family: Courier">}</span></span></div> </div> <img src ="http://www.aygfsteel.com/zeroline/aggbug/338312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zeroline/" target="_blank">zeroline</a> 2010-11-17 21:49 <a href="http://www.aygfsteel.com/zeroline/archive/2010/11/17/338312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡Ң</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ȫ</a>| <a href="http://" target="_blank">Ӱ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank">DZ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɾ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">差</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ݸ</a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">ƺ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ԫ</a>| <a href="http://" target="_blank">ƽң</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">书</a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank">Ȫ</a>| <a href="http://" target="_blank">̴</a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>